Autor Zpráva
Inpocasi
Profil
Jak v xml parseru otevřít více souborů, kód:

if(!($soubor = fopen("http://neco/c.xml", "r")));

else {
while ($d = fread($soubor, 4096)) {
if(!xml_parse($parser, $d, feof($soubor))) {
die("Chyba XML");
}
}

Chci aby (fopen) otevřelo více souborů a všechny projely tím xml parsrem.
nightfish
Profil
cyklem
$files = array("http://example.com/file.xml", "http://example.com/file2.xml");

foreach ($files as $f) {
if (!($soubor = fopen($f, "r"))) ...
...
...
else {
while(...) {
}
fclose($soubor);
}
}
Inpocasi
Profil
Vypíše pouze ten první soubor a potom napíše "Chyba xml"

$files = array("http://1.xml", "http://2.xml");



foreach ($files as $f) {

if(!($soubor = fopen($f, "r")));

else {
while ($d = fread($soubor, 4096)) {
if(!xml_parse($parser, $d, feof($soubor))) {
die("Chyba XML");
}
}



}

}
Xml soubory jsou v pořádku, výše uvedený kód je na konci celého parseru.
nightfish
Profil
nebude potřeba přes každý průchodem vytvořit nový parser pomocí xml_parser_create a po použití jej zničit pomocí xml_parser_free?
Inpocasi
Profil
nightfish
Sice je tam o něco víc znaků, ale funguje to, dík
Toto téma je uzamčeno. Odpověď nelze zaslat.

0