je vois pas comment je peux avoir un string de mon fichier XML que je modifie dans ma fonction :(
Version imprimable
je vois pas comment je peux avoir un string de mon fichier XML que je modifie dans ma fonction :(
Code:
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77 var xmlDocument; function modifieXML() { $.ajax( { type: "GET", url: "data.xml", xmlDocument: "data.xml", dataType: "xml", success: function(xml) { $(xml).find('jour').each( function() { var jour = $(this).find('day').text(); if (jour=="LUN") { alert( $(this).find('startAM').text()); $(this).find('startAM').nodeValue=AMdebutLundi; alert( $(this).find('startAM').text()); $(this).find('endAM').nodeValue=AMFinLundi; $(this).find('startPM').nodeValue=PMdebutLundi; $(this).find('endPM').nodeValue=PMFinLundi; } else if (jour=="MAR") { $(this).find('startAM').nodeValue=AMdebutMardi; $(this).find('endAM').nodeValue=AMFinMardi; $(this).find('startPM').nodeValue=PMdebutMardi; $(this).find('endPM').nodeValue=PMFinMardi; } else if (jour=="MER") { $(this).find('startAM').nodeValue=AMdebutMercredi; $(this).find('endAM').nodeValue=AMFinMercredi; $(this).find('startPM').nodeValue=PMdebutMercredi; $(this).find('endPM').nodeValue=PMFinMercredi; } else if (jour=="JEU") { $(this).find('startAM').nodeValue=AMdebutJeudi; $(this).find('endAM').nodeValue=AMFinJeudi; $(this).find('startPM').nodeValue=PMdebutJeudi; $(this).find('endPM').nodeValue=PMFinJeudi; } else if (jour=="VEND") { $(this).find('startAM').nodeValue=AMdebutVendredi; $(this).find('endAM').nodeValue=AMFinVendredi; $(this).find('startPM').nodeValue=PMdebutVendredi; $(this).find('endPM').nodeValue=PMFinVendredi; } else if (jour=="SAM") { $(this).find('startAM').nodeValue=AMdebutSamedi; $(this).find('endAM').nodeValue=AMFinSamedi; $(this).find('startPM').nodeValue=PMdebutSamedi; $(this).find('endPM').nodeValue=PMFinSamedi; } else if (jour=="DIM") { $(this).find('startAM').nodeValue=AMdebutDimanche; $(this).find('endAM').nodeValue=AMFinDimanche; $(this).find('startPM').nodeValue=PMdebutDimanche; $(this).find('endPM').nodeValue=PMFinDimanche; } }); } }); } $(document).ready( modifieXML() );
j'ai essayé d'utiliser une variable globaleCode:
1
2
3
4
5
6
7
8
9
10
11
12
13
14 function envoieXML() { $.ajax({ type: "POST", url: "serveur.php", processData: false, data: xmlDocument, success: function(msg){ alert( "Data Saved: " + msg ); } }); } $(document).ready( envoieXML() );
mais je sais pas comment la mettre dans ma fonction modifier() et si réelement cette variable globale que j'envoie ensuite dans envoieXML() et bien modifierCode:var xmlDocument;
de l'aide svp :(
il est certain que
etCode:
1
2
3
4
5
6
7
8
9
10 var xmlDocument; function modifieXML() { $.ajax( { type: "GET", url: "data.xml", xmlDocument: "data.xml", dataType: "xml", success: function(xml)
ne fonctionne pasCode:xmlDocument: "data.xml",
mais je vois pas comment faire pour envoyer dans ma fonction envoieXML() le fichier que j'ai modifier précédemment :(
de plus pour la modificatio j'ai fais
mais je sais pas si sa marche ....Code:$(this).find('startAM').nodeValue=AMdebutLundi;
il faut peut etre faire
Code:$(this).find('startAM').text(AMdebutLundi);
En gros :
1) comment modifier la valeur d'un noeud ?
2) comment recuperer le fichier XML modifier pour 'l'envoyer ?
Merci de votre aide.
voila mon code
Code:
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82 var documentXML; function modifieXML() { $.ajax( { type: "GET", url: "data.xml", dataType: "xml", success: function(xml) { $(xml).find('jour').each( function() { var jour = $(this).find('day').text(); if (jour=="LUN") { $(this).find('startAM').text(AMdebutLundi); $(this).find('endAM').nodeValue=AMFinLundi; $(this).find('startPM').nodeValue=PMdebutLundi; $(this).find('endPM').nodeValue=PMFinLundi; } else if (jour=="MAR") { $(this).find('startAM').nodeValue=AMdebutMardi; $(this).find('endAM').nodeValue=AMFinMardi; $(this).find('startPM').nodeValue=PMdebutMardi; $(this).find('endPM').nodeValue=PMFinMardi; } else if (jour=="MER") { $(this).find('startAM').nodeValue=AMdebutMercredi; $(this).find('endAM').nodeValue=AMFinMercredi; $(this).find('startPM').nodeValue=PMdebutMercredi; $(this).find('endPM').nodeValue=PMFinMercredi; } else if (jour=="JEU") { $(this).find('startAM').nodeValue=AMdebutJeudi; $(this).find('endAM').nodeValue=AMFinJeudi; $(this).find('startPM').nodeValue=PMdebutJeudi; $(this).find('endPM').nodeValue=PMFinJeudi; } else if (jour=="VEND") { $(this).find('startAM').nodeValue=AMdebutVendredi; $(this).find('endAM').nodeValue=AMFinVendredi; $(this).find('startPM').nodeValue=PMdebutVendredi; $(this).find('endPM').nodeValue=PMFinVendredi; } else if (jour=="SAM") { $(this).find('startAM').nodeValue=AMdebutSamedi; $(this).find('endAM').nodeValue=AMFinSamedi; $(this).find('startPM').nodeValue=PMdebutSamedi; $(this).find('endPM').nodeValue=PMFinSamedi; } else if (jour=="DIM") { alert($(this).find('startAM').text()); $(this).find('startAM').text(AMdebutDimanche); alert($(this).find('startAM').text()); $(this).find('endAM').nodeValue=AMFinDimanche; $(this).find('startPM').nodeValue=PMdebutDimanche; $(this).find('endPM').nodeValue=PMFinDimanche; } }); documentXML= xml; } }); }
a la fin je faisCode:documentXML= xml;
puis j'envoie au serveur;
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14 function envoieXML() { $.ajax({ type: "POST", url: "serveur.php", processData: false, data: documentXML, success: function(msg){ alert( "Data Saved: " + msg ); } }); } $(document).ready( envoieXML() );
dans firebug le POST que j'envoi dans le fichier XML les modification ne marche pas donc je sais pas du tout comment faire et ou ets le problème :
comment modifier la valeur d'un noeud ?
OUCode:$(this).find('endPM').nodeValue=PMFinDimanche;
Code:$(this).find('startAM').text(AMdebutDimanche);
ou le probleme vient peut etre de ma variable globale ?
Code:var documentXML;
J'ai besoin d'aide svp :(. merci.