I'm having trouble with nodeValue property.
No matter what..it gives me value null.
All other propeties are executing fine.
XML file:
<?xml version="1.0" encoding="ISO-8859-1"?>
<details>
<player>
<name>MSchu</name>
<poles>91</poles>
</player>
<player>
<name>Alonso</name>
<poles>25</poles>
</player>
</details>
And I'm running this code:
<html>
<head>
<script>
function loadXMLDoc(){
if (window.XMLHttpRequest){
xhttp=new XMLHttpRequest();
}
else{
xhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xhttp.open("GET","details.xml",false);
xhttp.send();
return xhttp.responseXML;
}
function show(){
xmlDoc = loadXMLDoc();
var x = xmlDoc.getElementsByTagName("player");
alert(x[0].nodeName); //This is printing player
alert(x[0].firstChild.nodeName) //This is printing name
y=x[0].firstChild;
alert(y.nodeValue); //This is printing null
}
</script>
</head>
<body>
<script>
show();
</script>
</body>
</html>