bonjour,
j'ai petit problème (encore un autre) avec la mise a jour d'un fichier xml:
le problème est qu'il modifie la premier "occurence" ou premier noeud et je ne comprend pas pourquoi:
voila le noeud avant la modif:
voila la code de modification :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13 <vol> <iditem>1</iditem> <agent>lemmouchi</agent> <date>29/08/2011</date> <numvolref>af7401</numvolref> <numvolarv>af7400</numvolarv> <from>lys</from> <sta>0820</sta> <numvoldep>af7401</numvoldep> <to>lys</to> <std>0850</std> </vol>
et voila le résultat, où none est une valeur par défaut si rien n'est saisie par l'utilisateur, pourtant en faisant un "echo" sur la variable $_SESSION('iditem') j'ai bine la valeur "1"
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
21
22
23
24
25
26
27
28
29
30 public function Writedatatoxml(){ $doc = new domdocument(); $doc->preserveWhiteSpace= false; $doc->load('prm/listevols.xml'); $doc->formatOutput = true; $xpath = new DOMXpath($doc); $elements = $xpath->query('//vol[iditem='.$_SESSION['iditem'].']'); $Qqaysxml= new qaysxml; $Qqaysxml->filexml='prm/listevols.xml'; //je vais alimenté le fichier xml avec toutes les variables sessions que j'ai créé foreach ($_SESSION as $cle=>$valeur){ // test si le noeud existe dans le fichier xml // si oui je modifie la valeur // si non je creer le noeud et sa valeur if ($Qqaysxml->existnoeud('vol',$cle)){ echo $cle.'='.$_SESSION[$cle].'<br/>'; $elements->item(0)->firstChild->nodeValue=$_SESSION[$cle]; } else{ $anotherNode = $doc->createElement($cle,$_SESSION[$cle]); $elements->item(0)->appendChild($anotherNode); } } $doc->save('prm/listevols.xml'); }
en testant je constate que la modification est toujours faite sur le premier noeud
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
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55 <vol> <iditem>"none"</iditem> ???????? <agent>lemmouchi</agent> <date>29/08/2011</date> <numvolref>af7401</numvolref> <numvolarv>af7400</numvolarv> <from>lys</from> <sta>0820</sta> <numvoldep>af7401</numvoldep> <to>lys</to> <std>0850</std> <errmessage>none</errmessage> <userconnected>lemmouchi</userconnected> <datevol>29/08/2011</datevol> <mh40>none</mh40> <mh10>none</mh10> <mallmcn>none</mallmcn> <mallmcw>none</mallmcw> <fh40>none</fh40> <fh10>none</fh10> <femlmcn>none</femlmcn> <femlmcw>none</femlmcw> <ch40>none</ch40> <ch10>none</ch10> <chdlmcn>none</chdlmcn> <chdlmcw>none</chdlmcw> <ih40>none</ih40> <ih10>none</ih10> <inflmcn>none</inflmcn> <inflmcw>none</inflmcw> <bnh40>none</bnh40> <bnh10>none</bnh10> <baglmcn>none</baglmcn> <baglmcw>none</baglmcw> <bwh40>none</bwh40> <bwh10>none</bwh10> <th40>none</th40> <th10>none</th10> <ata>none</ata> <atd>none</atd> <typevol>ARVDEP</typevol> <EscaleD>bud</EscaleD> <EscaleA>cia</EscaleA> <compagnieD>af</compagnieD> <compagnieA>af</compagnieA> <parkingA>a0</parkingA> <parkingD>a0</parkingD> <TavionA>cr1</TavionA> <TavionD>cr1</TavionD> <ImmatA>f-crj100</ImmatA> <ImmatD>f-crj100</ImmatD> <pagefuel>none</pagefuel> <pagefacturation>none</pagefacturation> </vol>
merci de votre aide.
cordialement
Partager