[AJAX] XML et utilisation de ResponseXML
Je voudrais écrire un fichier xml, et puis utilise les valeurs dans xml.
xml:
Code:
1 2 3 4 5 6 7
|
<?php
header('Content-Type: text/xml');
echo "<?xml version='1.0' encoding='ISO-8859-1'?>";
echo "<compname>"."ffff"."</compname>";
echo "<compname>"."ssss"."</compname>";
?> |
Javascript:
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
|
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET","domtecimp?d="+value_domtec,true);
var txt,x;
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
xmlDoc=xmlhttp.responseXML;
x=xmlDoc.getElementsByTagName("compname");
for(i=0;i<x.length;i++)
{
txt=txt+x[i].firstChild.nodeValue;
}
alert(txt);
}
};
xmlhttp.send(null); |
Quelqu'un peux m'aider à trouver mon érreur ? Merci avance !