Récupération des noeuds XML :'(
Salut à tous, j'ai petit souçis ,
je load un fichier xml , puis j'essaye de le parcourir pour le parser, mais cela ne fonctionne pas sous ie6 code :
fichier gabarit.xml
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
|
<?xml version="1.0" encoding="UTF-8"?>
<galeries>
<galerie>
<id>1</id>
<description>
<titre>première galerie</titre>
<auteur>moi</auteur>
<dateCreation>26/10/2007</dateCreation>
<theme>animaux</theme>
</description>
<images>
<image>
<id>1</id>
<link>blabla</link>
<description>de l'image</description>
<taille w="150" h="120"></taille>
<poid>200ko</poid>
</image>
<image>
<id>2</id>
<link>blabla</link>
<description>de l'image</description>
<taille w="150" h="120"></taille>
<poid>200ko</poid>
</image>
</images>
</galerie>
</galeries> |
code html :
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
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=windows-1250">
<meta name="generator" content="PSPad editor, www.pspad.com">
<title></title>
<script type="text/javascript">
var xmlDoc = "";
function importXML()
{
if (document.implementation && document.implementation.createDocument)
{
xmlDoc = document.implementation.createDocument("", "", null);
xmlDoc.onload = arborescence;
}
else if (window.ActiveXObject)
{
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.onreadystatechange = function () {
if (xmlDoc.readyState == 4) arborescence()
};
}
else
{
alert('Your browser can\'t handle this script');
return;
}
xmlDoc.load("gabarit.xml");
}
function arborescence(){
x = xmlDoc.getElementsByTagName('galeries');
alert(x[0].childNodes.length);
}
</script>
</head>
<body>
<input type="button" name="test" value="click" onclick="importXML()"">
</body>
</html> |
la fonction arborescence me renvoit bien 3 sous firefox mais plante sous IE ( objet requis ... )
Merci de votre aide ...