Salut,
j'ai besoin de savoir comment on peut déplacer un noued.
exemple :
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
20
 
<?xml version="1.0" encoding="UTF-8"?>
<photos>
<photo id="0">
<id>0</id>
<nom>Collines</nom>
<dateCreation>09-09-5</dateCreation>
<legende>aa</legende>
<url>images/ddkoala.jpg</url>
<position>0</position>
</photo>
<photo id="1">
<id>1</id>
<nom>Coucher de soleil</nom>
<dateCreation>09-09-5</dateCreation>
<legende>bb</legende>
<url>images/image2.jpg</url>
<position>1</position> 
</photo>
</photos>
devient :
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
20
 
<?xml version="1.0" encoding="UTF-8"?>
<photos>
<photo id="1">
<id>1</id>
<nom>Coucher de soleil</nom>
<dateCreation>09-09-5</dateCreation>
<legende>bb</legende>
<url>images/image2.jpg</url>
<position>0</position> 
</photo>
<photo id="0">
<id>0</id>
<nom>Collines</nom>
<dateCreation>09-09-5</dateCreation>
<legende>aa</legende>
<url>images/ddkoala.jpg</url>
<position>1</position>
</photo>
</photos>
j'ai testé ce code mais ça marche pas parce que au lieu ré-ordre la balise photo comme l'exemple, il a inséré sous la première balise.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
 
<?php
// création du nouvel objet document
$dom = new DomDocument();
// chargement à partir du fichier
$dom->load('photo.xml');
$new = $dom->getElementsByTagName("photo")->item(0);
$dom->getElementsByTagName("photo")->item(1)->appendChild($new);
 $dom->save('photo.xml');
?>
avez vous une réponse.
merci d'avance.