A voir également:
- Ecriture .xml (en php)
- Écriture facebook - Guide
- Ecriture en gras - Guide
- Xml download - Télécharger - Édition & Programmation
- Ecriture instagram - Guide
- Easy php - Télécharger - Divers Web & Internet
12 réponses
<?php header('Content-type: text/xml; charset=UTF-8'); $dom = new DOMDocument('1.0','utf-8'); $root = $dom->createElement('root'); $lignes = explode("\n", file_get_contents('fichier.txt')); foreach($lignes as $url) { if(!empty($url)) { $urlNode = $dom->createElement('url'); $locNode = $dom->createElement('loc',$url); $urlNode->appendChild($locNode); $root->appendChild($urlNode); } } $dom->appendChild($root); echo $dom->saveXML(); ?>
J'ai cette erreur lors de l'execution :
<b>Fatal error</b>: Allowed memory size of 134217728 bytes exhausted (tried to allocate 117682198 bytes) in <b>W:\var\www\ecriture xml\index.php</b> on line <b>7</b><br />
line 7 : "$lignes = explode("\n", file_get_contents('sitemap.txt'));"
Est-ce un pb avec la fonction file_get_contents ou un fichier .txt trop volumineux (113 Mo) ?
<b>Fatal error</b>: Allowed memory size of 134217728 bytes exhausted (tried to allocate 117682198 bytes) in <b>W:\var\www\ecriture xml\index.php</b> on line <b>7</b><br />
line 7 : "$lignes = explode("\n", file_get_contents('sitemap.txt'));"
Est-ce un pb avec la fonction file_get_contents ou un fichier .txt trop volumineux (113 Mo) ?
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question
C'est le fichier qui dépasse la taille de traitement autorisée dans le php.ini
Regarde dans la doc ou la faq de ton hébergeur ou contactes-les.
Regarde dans la doc ou la faq de ton hébergeur ou contactes-les.
Je travaille en local =)
Est-ce cette ligne qu'il faudrait que je modifie dans le php.ini :
" memory_limit = 128M; " ou pas?
Est-ce cette ligne qu'il faudrait que je modifie dans le php.ini :
" memory_limit = 128M; " ou pas?
J'ai beau changer la valeur de cette ligne dans le php.ini et rien ... Toujours la même erreur :( :
"<b>Fatal error</b>: Allowed memory size of 134217728 bytes exhausted (tried to allocate 117682198 bytes) in <b>W:\var\www\ecriture xml\index.php</b> on line <b>7</b><br />"
"<b>Fatal error</b>: Allowed memory size of 134217728 bytes exhausted (tried to allocate 117682198 bytes) in <b>W:\var\www\ecriture xml\index.php</b> on line <b>7</b><br />"
J'ai essayer 64, 256, 512 et même 1024...
Sa change même pas l'erreur c'est toujours : "...Allowed memory size of 134217728 bytes exhausted (tried to allocate 117682198..."
Sa change même pas l'erreur c'est toujours : "...Allowed memory size of 134217728 bytes exhausted (tried to allocate 117682198..."
Est-ce que tu mets bien le "M" après le chiffre ?
Ben en fait, pour les gros fichiers .txt, j'ai toujours un problème (memory_limit)
Mais sinon ta méthode fonctionne parfaitement, juste il me faudrait rajouter ces ligne en debut de .xml :
<?xml version="1.0" encoding="UTF-8" ?>
<urlset xmlns="https://www.sitemaps.org/schemas/sitemap/0.9/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://www.sitemaps.org/schemas/sitemap/0.9/ https://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
Mais sinon ta méthode fonctionne parfaitement, juste il me faudrait rajouter ces ligne en debut de .xml :
<?xml version="1.0" encoding="UTF-8" ?>
<urlset xmlns="https://www.sitemaps.org/schemas/sitemap/0.9/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://www.sitemaps.org/schemas/sitemap/0.9/ https://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
Style : xmlns="https://www.google.com/schemas/sitemap/0.84/"
<?xml version="1.0" encoding="UTF-8" ?>
<urlset xmlns="https://www.sitemaps.org/schemas/sitemap/0.9/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://www.sitemaps.org/schemas/sitemap/0.9/ https://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
[...]
Une ossature de type sitemap.