Bonjour,

J'ai un problème avec le code ci-dessous : il marche sous Firefox mais nada avec IE 7 ("DomParser est indéfini").
Quelqu'un a une idée?
Merci

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
 
<html>
<body>
<script>
var xmlstring = '<?xml version="1.0"?>\
<root>\
	<data>\
		<row>\
			<cell>Admiral</cell>\
			<cell>Melon</cell>\
			<cell>Carrot</cell>\
		</row>\
		<row>\
			<cell>Captain</cell>\
			<cell>Banana</cell>\
			<cell>Zucchini</cell>\
		</row>\
	</data>\
	<data>\
		<row>\
			<cell>Midshipman</cell>\
			<cell>Orange</cell>\
			<cell>Potatoe</cell>\
		</row>\
	</data>\
</root>';
 
// convert the string to an XML object
var xmlobject = (new DOMParser()).parseFromString(xmlstring, "text/xml");
// get the XML root item
var root = xmlobject.getElementsByTagName('root')[0];
 
for (var iNode = 0; iNode < root.childNodes.length; iNode++) {
   var node = root.childNodes.item(iNode);
   for (i = 0; i < node.childNodes.length; i++) {
      var sibling = node.childNodes.item(i);
      for (x = 0; x < sibling.childNodes.length; x++) {
         var sibling2 = sibling.childNodes.item(x);
         if (sibling2.childNodes.length > 0) {
            var sibling3 = sibling2.childNodes.item(0);
            alert(sibling3.data);
         }
      }
   }
}
</script>
</body>
</html>