Ciao a tutti/e,
ho questo script per aggiungere un childnode ad un file .xml:
Ora, lo script lo aggiunge solo al primp item(0), ma vorrei poterlo aggiungere a tutti i nodi della lista (article). Come devo fare?Codice PHP:
$xdoc = new DomDocument;
$xdoc->Load('article.xml');
$festa = $xdoc -> getElementsByTagName('article') -> item(0);
$newElement = $xdoc ->createElement('festa');
$txtNode = $xdoc ->createTextNode ("Primo Maggio");
$newElement -> appendChild($txtNode);
$festa -> appendChild($newElement);
$test = $xdoc -> save("article.xml");
echo "[b]Dati aggiunti[/b]"