parce que tu crois que c'est facile la saisie avec des doigts de grenouilles ?Citation:
Le thml() ?
:dehors:
Version imprimable
parce que tu crois que c'est facile la saisie avec des doigts de grenouilles ?Citation:
Le thml() ?
:dehors:
merci nosmo :oops:
html() ...
donc le contenu de ta balise virtuelle $xml
au départ tu y colles ton xml récupèré
après modification tu récupère son contenuCode:$xml=$('<XML/>').html(stringxml);
qui est le code xml modifié que tu n'as plus qu'à sauvegarder selon ta méthode habituelleCode:$xml.html();
Ok, je pense avoir compris.
Mais, je viens de me rendre compte qu'il y avait une erreur "« stringxml » est indéfini" ?
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 function Tri(P_Fichier) { WFichier = G_RepXML + "UtilisateursVista.xml"; $(document).ready( function(){ $.ajax( { type: "GET", url: WFichier, async: false, // Empêche la poursuite du code tant que la fonction n'est pas terminée. dataType: "xml", error: function (jqXHR, textStatus, errorThrown) { alert("Problème avec le fichier XML, veuillez vérifier le fichier '" + WFichier + "'." + G_CrLf + "Traitement impossible."); // window.close(); window.location.reload(); }, success: function(xml) { $( function(){ function su(a,b){ var compA = $(a).find('EMAIL').text().toLowerCase(); var compB = $(b).find('EMAIL').text().toLowerCase(); return (compA < compB) ? -1 : (compA > compB) ? 1 : 0; } $xml=$('<XML/>').html(stringxml); $utilisateurs= $xml.find('UTILISATEUR'); $utilisateurs.sort(su); $xml.append($utilisateurs); $xml.find('UTILISATEUR').each( function(){ alert($xml.html()); // INSERER L'ECRITURE DU FICHIER ICI ? console.log ( $(this).find('EMAIL').text() ); }) }) } // FIN SUCCES }); }); }
forcément, le but est de mettre le retour de ton ajax dans la balise ...
devrait êtreCode:success: function(xml)
ou ton conserves xml et tu le mets dans le html()Code:success: function(xmlstring)
Bon alors ça donne ça :
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 function Tri(P_Fichier) { WFichier = G_RepXML + "UtilisateursVista.xml"; $(document).ready( function(){ $.ajax( { type: "GET", url: WFichier, async: false, // Empêche la poursuite du code tant que la fonction n'est pas terminée. dataType: "xml", error: function (jqXHR, textStatus, errorThrown) { alert("Problème avec le fichier XML, veuillez vérifier le fichier '" + WFichier + "'." + G_CrLf + "Traitement impossible."); // window.close(); window.location.reload(); }, success: function(stringxml) { $( function(){ function su(a,b){ var compA = $(a).find('NOM').text().toLowerCase(); var compB = $(b).find('NOM').text().toLowerCase(); return (compA < compB) ? -1 : (compA > compB) ? 1 : 0; } $xml=$('<XML/>').html(stringxml); $utilisateurs= $xml.find('UTILISATEUR'); $utilisateurs.sort(su); $xml.append($utilisateurs); $xml.find('UTILISATEUR').each( function(){ alert($(this).find('NOM').text()); // INSERER L'ECRITURE DU FICHIER ICI ? console.log ( $(this).find('NOM').text() ); }) }) } // FIN SUCCES }); }); }
Mais j'ai l'erreur suivante :
SCRIPT5007: Impossible d’obtenir la propriété « ownerDocument » d’une référence null ou non définie
Fichier : jquery.js, ligne : 1445, colonne : 2
:(Code:
1
2
3
4
5
6
7
8 success: function(stringxml) { $( function(){ function su(a,b){ var compA = $(a).find('NOM').text().toLowerCase(); var compB = $(b).find('NOM').text().toLowerCase(); return (compA < compB) ? -1 : (compA > compB) ? 1 : 0; }
vaut document.ready ... dcon en gros rine à faire à cet endroit là ;..Code:$( function(){
déclarer une fcontion sur un retour d'ajax est aussi maladroits ... déclare la fonction su ailleurs ... en dehors du success ajax voire même en dehors de l'ajax
Je suis désolé, mais je ne comprends pas ce qu'il faut faire :oops:
J'ai vraiment besoin qu'on me prenne par la main :? (Et avec des pattes de grenouilles, c'est plus facile :mrgreen:)
Je n'ai pas pour habitue de coder poru les autres... je montre la voie
Relis bien mes messages, les différents problèmes y sont énumérés et les étapes pour les résoudre.
Ton document ready n'a rien a faire DANS ton ajax
ni la déclaration du su() ...
Je suis désolé, mais je ne sais pas faire.
Encore une fois, je donne un coup de main, mais ce n'est pas mon métier et malheureusement, je n'ai pas le temps et je ne peux pas faire de formations comme j'aimerai.
C'est pour cela que je m'adresse à ceux qui savent et une fois que c'est fait, je sais reproduire ;)
J'ai fait ça, mais ça ne fonctionne toujours pas :
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 function Tri(P_Fichier) { WFichier = G_RepXML + "UtilisateursVista.xml"; $(document).ready( function(){ $.ajax( { type: "GET", url: WFichier, async: false, // Empêche la poursuite du code tant que la fonction n'est pas terminée. dataType: "xml", error: function (jqXHR, textStatus, errorThrown) { alert("Problème avec le fichier XML, veuillez vérifier le fichier '" + WFichier + "'." + G_CrLf + "Traitement impossible."); // window.close(); window.location.reload(); }, success: function(xml) { $( function(){ $xml=$('<XML/>').html(xml); $utilisateurs= $xml.find('UTILISATEUR'); $utilisateurs.sort(su); $xml.append($utilisateurs); $xml.find('UTILISATEUR').each( function(){ alert($xml.html()); // INSERER L'ECRITURE DU FICHIER ICI ? console.log ( $(this).find('NOM').text() ); }) }) } // FIN SUCCES }); }); } function su(a,b){ var compA = $(a).find('NOM').text().toLowerCase(); var compB = $(b).find('NOM').text().toLowerCase(); return (compA < compB) ? -1 : (compA > compB) ? 1 : 0; }
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 function Tri(P_Fichier) { WFichier = G_RepXML + "UtilisateursVista.xml"; $(document).ready( function(){ // <= je ne vois pas trop ce qu'un docuement ready vient faire DANS une fonction $.ajax( { type: "GET", url: WFichier, async: false, // Empêche la poursuite du code tant que la fonction n'est pas terminée. dataType: "xml", error: function (jqXHR, textStatus, errorThrown) { alert("Problème avec le fichier XML, veuillez vérifier le fichier '" + WFichier + "'." + G_CrLf + "Traitement impossible."); // window.close(); window.location.reload(); }, success: function(xml) { $( function(){ // <= ça c'est un équivament de document ready donc rien à faire là $xml=$('<XML/>').html(xml); $utilisateurs= $xml.find('UTILISATEUR'); $utilisateurs.sort(su); $xml.append($utilisateurs); $xml.find('UTILISATEUR').each( function(){ alert($xml.html()); // INSERER L'ECRITURE DU FICHIER ICI ? console.log ( $(this).find('NOM').text() ); }) }) } // FIN SUCCES }); }); } function su(a,b){ var compA = $(a).find('NOM').text().toLowerCase(); var compB = $(b).find('NOM').text().toLowerCase(); return (compA < compB) ? -1 : (compA > compB) ? 1 : 0; }
Holala, je suis complètement paumé.
Encore une fois, j'apprends par mimétisme ;)
Ce serait vraiment sympa que tu acceptes de mettre les doigts dans l'bouzin ;) même si je salue ta patience avec moi ;)
Nouvelle version, mais même résultat :
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 WFichier = G_RepXML + "UtilisateursVista.xml"; $.ajax( { type: "GET", url: WFichier, async: false, // Empêche la poursuite du code tant que la fonction n'est pas terminée. dataType: "xml", error: function (jqXHR, textStatus, errorThrown) { alert("Problème avec le fichier XML, veuillez vérifier le fichier '" + WFichier + "'." + G_CrLf + "Traitement impossible."); // window.close(); window.location.reload(); }, success: function(xml) { $xml=$('<XML/>').html(xml); $utilisateurs= $xml.find('UTILISATEUR'); $utilisateurs.sort(su); $xml.append($utilisateurs); $xml.find('UTILISATEUR').each( function(){ alert($xml.html()); // INSERER L'ECRITURE DU FICHIER ICI ? console.log ( $(this).find('NOM').text() ); }); } // FIN SUCCES }); } function su(a,b){ var compA = $(a).find('NOM').text().toLowerCase(); var compB = $(b).find('NOM').text().toLowerCase(); return (compA < compB) ? -1 : (compA > compB) ? 1 : 0; }
Bon, c'est la grosse galère : je viens de me rendre compte que le fichier XML était dénaturé dés que je le modifiais dynamiquement, donc tout ce que j'ai fait ne sert à rien, fais c**** !
En fait, après une modification, le fichier se charge bien dans Firefox, mais pas dans IE (j'ai une page blanche).
Lorsque je regarde le fichier avec Notepad, il est encodé UTF-16LE au lieu de UTF-8 ???
Et je pense que tous mes problèmes viennent de là, mais comment forcer le UTF-8 ?
Est-ce qu'un bonne âme pourrait m'aider à solutionner le problème ?
Je sais que certaines personnes oriente, j'ai bien compris, mais là, j'ai vraiment besoin qu'on m'aide, qu'on corrige mon code, svp.
(Je ne suis pas un dev pro, j'aide juste une équipe)
Merci, vraiment merci d'avance.
Voici le 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147 function EcritureFichierXML(P_Type) { // P_Type = "SUPP", "MODIF" // Copie du fichier avant l'écriture => UtilisateursVista.xml.BAK CopieFichierXML("UtilisateursVista.xml", "UtilisateursVista.xml.BAK"); var WActx_FSO = new ActiveXObject('Scripting.FileSystemObject'); WFichierXML = WActx_FSO.CreateTextFile(G_FICHIER, true, true); WLigne = '<?xml version="1.0" encoding="UTF-8" ?>'; WFichierXML.Writeline(WLigne); WLigne = "<UTILISATEURS>"; WFichierXML.Writeline(WLigne); WLigne = G_Tab + "<LISTE>"; WFichierXML.Writeline(WLigne); if (P_Type == "AJOUT") { // Ecriture de l'utilisateur à ajouter WNom_UTIL = window.Form_Etudes.ID_AJOUT_NOM.value; WPrenom_UTIL = window.Form_Etudes.ID_AJOUT_PRENOM.value; WEmail_UTIL = window.Form_Etudes.ID_AJOUT_EMAIL.value; WEmail_UTIL = WEmail_UTIL.toLowerCase(); WParis_UTIL = window.Form_Etudes.ID_LI_PARIS.value; WVistaSC_UTIL = window.Form_Etudes.ID_LI_SC.value; WVistaQSE_UTIL = window.Form_Etudes.ID_LI_QSE.value; WVistaCRAQ_UTIL = window.Form_Etudes.ID_LI_CRAQ.value; WUtil_UTIL = window.Form_Etudes.ID_LI_UTIL.value; WPotAG_UTIL = window.Form_Etudes.ID_LI_POTAG.value; WLigne = G_Tab + G_Tab + "<UTILISATEUR>"; WFichierXML.Writeline(WLigne); WLigne = G_Tab + G_Tab + G_Tab + "<NOM>" + WNom_UTIL + "</NOM>"; WFichierXML.Writeline(WLigne); WLigne = G_Tab + G_Tab + G_Tab + "<PRENOM>" + WPrenom_UTIL + "</PRENOM>"; WFichierXML.Writeline(WLigne); WLigne = G_Tab + G_Tab + G_Tab + "<EMAIL>" + WEmail_UTIL + "</EMAIL>"; WFichierXML.Writeline(WLigne); WLigne = G_Tab + G_Tab + G_Tab + "<PARIS>" + WParis_UTIL + "</PARIS>"; WFichierXML.Writeline(WLigne); WLigne = G_Tab + G_Tab + G_Tab + "<VISTA_SURVOLS_COMMUNES>" + WVistaSC_UTIL + "</VISTA_SURVOLS_COMMUNES>"; WFichierXML.Writeline(WLigne); WLigne = G_Tab + G_Tab + G_Tab + "<VISTA_QSE>" + WVistaQSE_UTIL + "</VISTA_QSE>"; WFichierXML.Writeline(WLigne); WLigne = G_Tab + G_Tab + G_Tab + "<VISTA_QSE_CRQA>" + WVistaCRAQ_UTIL + "</VISTA_QSE_CRQA>"; WFichierXML.Writeline(WLigne); WLigne = G_Tab + G_Tab + G_Tab + "<JOURNEE_ORDINAIRE>OUI</JOURNEE_ORDINAIRE>"; WFichierXML.Writeline(WLigne); WLigne = G_Tab + G_Tab + G_Tab + "<JOURNEE_CHARGEE>OUI</JOURNEE_CHARGEE>"; WFichierXML.Writeline(WLigne); WLigne = G_Tab + G_Tab + G_Tab + "<MAINTENANCE>NON</MAINTENANCE>"; WFichierXML.Writeline(WLigne); WLigne = G_Tab + G_Tab + G_Tab + "<SUPERVISION>NON</SUPERVISION>"; WFichierXML.Writeline(WLigne); WLigne = G_Tab + G_Tab + G_Tab + "<GESTION_UTILISATEURS>" + WUtil_UTIL + "</GESTION_UTILISATEURS>"; WFichierXML.Writeline(WLigne); WLigne = G_Tab + G_Tab + G_Tab + "<VISTA_STAT>OUI</VISTA_STAT>"; WFichierXML.Writeline(WLigne); WLigne = G_Tab + G_Tab + G_Tab + "<POTAG>" + WPotAG_UTIL + "</POTAG>"; WFichierXML.Writeline(WLigne); WLigne = G_Tab + G_Tab + "</UTILISATEUR>"; WFichierXML.Writeline(WLigne); } i = 1; // Il faut commencer à 1 pour ne pas compter la ligne d'entête WNbLigTab = document.getElementById("Tab_Util").rows.length - 2; // Il ne faut pas compter la ligne d'entête while (i <= WNbLigTab) { if (P_Type == "SUPP") { WI_Tab = i; } else { WI_Tab = i - 1; } WLigne = G_Tab + G_Tab + "<UTILISATEUR>"; WFichierXML.Writeline(WLigne); WIDNom = "ID_Input_Nom_" + WI_Tab; WIDPrenom = "ID_Input_Prenom_" + WI_Tab; WIDEmail = "ID_Input_Email_" + WI_Tab; WIDParis = "L_Paris_" + WI_Tab; WIDVistaSC = "L_VistaSC_" + WI_Tab; WIDVistaQSE = "L_VistaQSE_" + WI_Tab; WIDVistaQSE_CRAQ = "L_VistaQSE_CRQA_" + WI_Tab; WIDUtil = "L_Utilisateur_" + WI_Tab; WIDPotAG = "L_VistaQSE_POTAG_" + WI_Tab; WNom = document.getElementById(WIDNom).value; WPrenom = document.getElementById(WIDPrenom).value; WEmail = document.getElementById(WIDEmail).value; WParis = document.getElementById(WIDParis).value; WVistaSC = document.getElementById(WIDVistaSC).value; WVistaQSE = document.getElementById(WIDVistaQSE).value; WVistaQSE_CRAQ = document.getElementById(WIDVistaQSE_CRAQ).value; WJo = "OUI"; // Valeur forcée pour la compatibilité WJc = "OUI"; // Valeur forcée pour la compatibilité WMaintenance = "NON"; // Valeur forcée pour la compatibilité WSupervision ="NON"; // Valeur forcée pour la compatibilité WUtil = document.getElementById(WIDUtil).value; WStat = "OUI"; // Valeur forcée pour la compatibilité WPotAG = document.getElementById(WIDPotAG).value; WLigne = G_Tab + G_Tab + G_Tab + "<NOM>" + WNom + "</NOM>"; WFichierXML.Writeline(WLigne); WLigne = G_Tab + G_Tab + G_Tab + "<PRENOM>" + WPrenom + "</PRENOM>"; WFichierXML.Writeline(WLigne); WLigne = G_Tab + G_Tab + G_Tab + "<EMAIL>" + WEmail + "</EMAIL>"; WFichierXML.Writeline(WLigne); WLigne = G_Tab + G_Tab + G_Tab + "<PARIS>" + WParis + "</PARIS>"; WFichierXML.Writeline(WLigne); WLigne = G_Tab + G_Tab + G_Tab + "<VISTA_SURVOLS_COMMUNES>" + WVistaSC + "</VISTA_SURVOLS_COMMUNES>"; WFichierXML.Writeline(WLigne); WLigne = G_Tab + G_Tab + G_Tab + "<VISTA_QSE>" + WVistaQSE + "</VISTA_QSE>"; WFichierXML.Writeline(WLigne); WLigne = G_Tab + G_Tab + G_Tab + "<VISTA_QSE_CRQA>" + WVistaQSE_CRAQ + "</VISTA_QSE_CRQA>"; WFichierXML.Writeline(WLigne); WLigne = G_Tab + G_Tab + G_Tab + "<JOURNEE_ORDINAIRE>" + WJo + "</JOURNEE_ORDINAIRE>"; WFichierXML.Writeline(WLigne); WLigne = G_Tab + G_Tab + G_Tab + "<JOURNEE_CHARGEE>" + WJc + "</JOURNEE_CHARGEE>"; WFichierXML.Writeline(WLigne); WLigne = G_Tab + G_Tab + G_Tab + "<MAINTENANCE>" + WMaintenance + "</MAINTENANCE>"; WFichierXML.Writeline(WLigne); WLigne = G_Tab + G_Tab + G_Tab + "<SUPERVISION>" + WSupervision + "</SUPERVISION>"; WFichierXML.Writeline(WLigne); WLigne = G_Tab + G_Tab + G_Tab + "<GESTION_UTILISATEURS>" + WUtil + "</GESTION_UTILISATEURS>"; WFichierXML.Writeline(WLigne); WLigne = G_Tab + G_Tab + G_Tab + "<VISTA_STAT>" + WStat + "</VISTA_STAT>"; WFichierXML.Writeline(WLigne); WLigne = G_Tab + G_Tab + G_Tab + "<POTAG>" + WPotAG + "</POTAG>"; WFichierXML.Writeline(WLigne); WLigne = G_Tab + G_Tab + "</UTILISATEUR>"; WFichierXML.Writeline(WLigne); i = i + 1; } WLigne = G_Tab + "</LISTE>"; WFichierXML.Writeline(WLigne); WLigne = "</UTILISATEURS>"; WFichierXML.Writeline(WLigne); WFichierXML.close(); alert("Ecriture du fichier XML terminée."); //Tri du fichier XML. ////// Tri(G_FICHIER); window.location.reload(); }