Your XML file is not proper, there can be only one root element. Also since you have not posted the entire code, I would give you a small example on how to go about things:
// Javascript file
<html>
<head>
<title>XML DOM</title>
<script type="text/javascript">
var xmlDoc;
function parse()
{
alert('in parse');
if(window.ActiveXObject)
{
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async = false;
xmlDoc.load("notes.xml");
display();
}
else if(document.implementation.createDocument)
{
xmlDoc = document.implementation.createDocument("", "", null);
xmlDoc.load("notes.xml");
xmlDoc.onload = display;
}
else
{
alert("Browser doesn't support XML DOM manipulation");
}
alert('out parse');
}
function display()
{
alert('In display');
document.getElementById('b1').innerHTML = xmlDoc.getElementsByTagName("b")[0].childNodes[0].nodeValue;
document.getElementById('c1').innerHTML = xmlDoc.getElementsByTagName("c")[0].childNodes[0].nodeValue;
document.getElementById('b2').innerHTML = xmlDoc.getElementsByTagName("b")[1].childNodes[0].nodeValue;
document.getElementById('c2').innerHTML = xmlDoc.getElementsByTagName("c")[1].childNodes[0].nodeValue;
}
</script>
</head>
<body onload="parse();">
<p>b1: <span id="b1"></span></p>
<p>c1: <span id="c1"></span></p>
<p>b2: <span id="b2"></span></p>
<p>c2: <span id="c2"></span></p>
</body>
</html> // XML Document
<root>
<a>
<b>100</b>
<c>200</c>
</a>
<a>
<b>300</b>
<c>400</c>
</a>
</root>
In case of any queries, do ask again.
~s.o.s~
Failure as a human
Administrator
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 734