bonjour,
j'ai un souci au niveau de l'extraction d'un fichier XML vers du PHP
au niveau des accents ,le XML est en "ISO-8859-1" je vous transmet mes deux codes XML et PHP le souci se situ au niveau des accents.
j'arrive a récupérer le titre en "ISO-8859-1" dans "Titre2" mais je n'arrive pas a injecter la valeur en format "ISO-8859-1" dans "deroule2"
pour visualiser le problème vous pouvez mettre un "é" dans le fichier XML dans l’élément administration exemple "Administrationé" et la mon PHP ne fonctionne plus comme je veux
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
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<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?> <Organigramme> <Informations> </Informations> <Administration_1> <Informations> </Informations> <Direction_1> <Informations> </Informations> <Utilisateur> <prenom>prenom1</prenom> <nom>nom1</nom> </Utilisateur> <Utilisateur> <prenom>prenom2</prenom> <nom>nom2</nom> </Utilisateur> <Utilisateur> <prenom>prenom3</prenom> <nom>nom3</nom> </Utilisateur> <sd1> <Utilisateur> <prenom>prenom3</prenom> <nom>nom3</nom> </Utilisateur> </sd1> </Direction_1> <Directeur_1> <Informations> </Informations> <Utilisateur> <prenom>prenom4</prenom> <nom>nom4</nom> </Utilisateur> </Directeur_1> <Direction_3> <Informations> </Informations> <Directeurs_1> <Informations> </Informations> <Utilisateur> <prenom>prenom5</prenom> <nom>nom5</nom> </Utilisateur> </Directeurs_1> <Service_1> <Informations> </Informations> <Utilisateur> <prenom>prenom6</prenom> <nom>nom6</nom> </Utilisateur> </Service_1> <Service_2> <Informations> </Informations> <Utilisateur> <prenom>prenom7</prenom> <nom>nom7</nom> </Utilisateur> </Service_2> <Service_3> <Informations> </Informations> <Utilisateur> <prenom>prenom8</prenom> <nom>nom8</nom> </Utilisateur> </Service_3> </Direction_3> <Direction_4> <Informations> </Informations> <Directeurs_1> <Informations> </Informations> <Utilisateur> <prenom>prenom9</prenom> <nom>nom9</nom> </Utilisateur> </Directeurs_1> <Service_1> <Informations> </Informations> <Utilisateur> <prenom>prenom10</prenom> <nom>nom10</nom> </Utilisateur> </Service_1> <Service_2> <Informations> </Informations> <Utilisateur> <prenom>prenom11</prenom> <nom>nom11</nom> </Utilisateur> </Service_2> <Service_3> <Informations> </Informations> <Utilisateur> <prenom>prenom12</prenom> <nom>nom12</nom> </Utilisateur> </Service_3> </Direction_4> <Pole_1> <Informations> </Informations> <DG_1> <Informations> </Informations> <Utilisateur> <prenom>prenom13</prenom> <nom>nom13</nom> </Utilisateur> <Utilisateur> <prenom>prenom14</prenom> <nom>nom14</nom> </Utilisateur> </DG_1> <Services_1> <Informations> </Informations> <Utilisateur> <prenom>prenom15</prenom> <nom>nom15</nom> </Utilisateur> <Utilisateur> <prenom>prenom16</prenom> <nom>nom16</nom> </Utilisateur> </Services_1> </Pole_1> </Administration_1> </Organigramme>
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
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 <meta http-equiv="Content-Type" content="text/html"; charset="ISO-8859-1"> <html> <head> <link rel="stylesheet" type="text/css" href="styles.css"> <title>TEST</title> </head> <body bgcolor="#333399"> <!------------------------------ CHARGEMENT XML ------------------------------------------------------> <?php $dom = new DOMDocument(); $dom->load("orgab.xml"); ?> <!------------------------------------------------------------------------------------------------------> <!------------------------------------------------------------------------------------------------------> <?php function Titre1 ($dom) { $parent=$dom->firstChild->nodeName; print("<center><font size=\"3\" face=\"Arial\"><b>$parent</b></font></center></br>"); } ?> <!------------------------------------------------------------------------------------------------------> <?php function Deroule1($dom) { $parent=$dom->firstChild->nodeName; $domliste = $dom->getElementsByTagName($parent); $tab_tag = array(); if ($domliste->length == 1) { $elements = $domliste->item(0)->childNodes; $mon_champ = isset($_POST['mon_champ']) ? $_POST['mon_champ'] : ''; foreach ($elements as $node ) { if ($node->nodeType == 1) $tab_tag[] = $node->nodeName; { if( $node->nodeName != "#text" && $node->nodeName != "Informations" && $node->nodeName != "membre_de" ) { echo '<form action="new1.php" method="post">'; echo '<input type="submit" name="mon_champ" value="'; echo utf8_decode($node->nodeName); echo '"/></form></center>'; } } } } } ?> <!------------------------------------------------------------------------------------------------------> <?php function Titre2 ($dom) { if(isset ($_POST['mon_champ'])) { $mon_champ =$_POST['mon_champ']; } echo '<center><font size=\"3\" face=\"Arial\"><b>'; echo @$mon_champ; echo '</b></font></center></br>'; } ?> <!------------------------------------------------------------------------------------------------------> <?php function Deroule2($dom) { if(isset ($_POST['mon_champ'])) { $mon_champ =$_POST['mon_champ']; } $domliste = $dom->getElementsByTagName(@$mon_champ); $tab_tag = array(); if ($domliste->length == 1) { $elements = $domliste->item(0)->childNodes; $mon_champ = isset($_POST['mon_champ']) ? $_POST['mon_champ'] : ''; foreach ($elements as $node ) { if ($node->nodeType == 1) $tab_tag[] = $node->nodeName; { if( $node->nodeName != "#text" && $node->nodeName != "Informations" && $node->nodeName != "membre_de" ) { echo '<form action="new1.php" method="post">'; echo '<input type="submit" name="mon_champ" value="'; echo utf8_decode($node->nodeName); echo '"/></form></center>'; if( $node->nodeName == "Utilisateur") { echo utf8_decode($node->nodeValue); } } } } } } ?> <!------------------------------------------------------------------------------------------------------> <!------------------------------------------------------------------------------------------------------> <!---------------------- DIV 2 ---------------------------------------------------------> <div align="center" class="conteneur2"><center></center><div class="bloc2"> <?php Titre1 ($dom); Deroule1($dom); ?> </div></div> <!------------------------------------------------------------------------------------------------------> <!------------------------------------------------------------------------------------------------------> <!---------------------- DIV 3 ---------------------------------------------------------> <div align="center" class="conteneur3"><center></center><div class="bloc3"> <?php Titre2 ($dom); Deroule2($dom); ?> </div></div> <!------------------------------------------------------------------------------------------------------> </body> </html>
Partager