<html>
<head>
<script src="/demo/loadxmldoc.js">
</script>
</head>
<body>
<script>
//check if the first node is an element node
function get_firstchild(n)
{
x=n.firstChild;
while (x.nodeType!=1)
{
x=x.nextSibling;
}
return x;
}
xmlDoc=loadXMLDoc("books.xml");
x=get_firstchild(xmlDoc);
document.write("Nodename: " + x.nodeName);
document.write(" (nodetype: " + x.nodeType + ")<br>");
//Get the first child node of the root element
y=get_firstchild(xmlDoc.documentElement);
document.write("Nodename: " + y.nodeName);
document.write(" (nodetype: " + y.nodeType);
</script>
</body>
</html>