Bonjour tout le monde,

J'essaie de supprimer un nœud qui a un ID précis de mon fichier xml , alors j'ai fait le script suivant mais ca donne rien

Code : 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
<?php
$string = '<?xml version="1.0" encoding="UTF-8"?>
<test>
  <node>
    <sub1>Test</sub1>
    <sub2>Test2</sub2>
  </node>
  <node id="et_1">
    <sub3>Test3</sub3>
    <sub4>Test4</sub4>
  </node>
</test>
';
 
$xml = simplexml_load_string($string);
echo "<b>Starting string:</b><br /><pre>".htmlentities($xml->asxml())."</pre>";
unset($xml->node[id='1_1']);
echo "<b>resultat:</b><br /><pre>".htmlentities($xml->asxml())."</pre>";
?>
Quelqu'un a une solution??

Merci d'avance