Bonjour,
Je cherche a supprimer le dernier noeud <entry>.
Voici la structure du xml :
Code XML : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 <feed xmlns="http://www.w3.org/2005/Atom"> <id>http://localhost/zf/public/</id> <entry> <id>6</id> <title>Test RSS1</title> <updated>2007-08-24T09:56:37+02:00</updated> <link href="http://localhost/"/> </entry> <entry> <id>7</id> <title>Test RSS 2</title> <updated>2007-08-24T09:56:51+02:00</updated> <link href="http://localhost/"/> </entry> <entry> <id>8</id> <title>Test RSS 3</title> <updated>2007-08-24T09:57:15+02:00</updated> <link href="http://localhost/"/> </entry> </feed>
J'ai trouver une solution correct comme ceci :
C'est assez moche Est ce qu'il n'y a pas moyen d'utiliser un lastChild ? (j'ai pas trouver comment)
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11 // Load Xml $dom = new DOMDocument(); $dom->preserveWhiteSpace = false; $dom->formatOutput = true; $dom->load('public/feed/news.xml'); $res = $dom->getElementsByTagName('entry'); $numFeed = $res->length - 1; $entry = $dom->getElementsByTagName('entry')->item($numFeed); $entry->parentNode->removeChild($entry);
Yoshio
Partager