<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> <HTML> <HEAD> <TITLE>Loadxml</TITLE> </HEAD> <BODY ONLOAD="Parse()"> <SCRIPT> function Parse() { // Create a Document object and report the results. // The following instantiate different versions of the MSXML parser // Version 1 ProgID: Microsoft.XMLDOM // Version 2 ProgID: MSXML2.DOMDocument // Version 3 ProgID: MSXML2.DOMDocument.3.0 // var xmlDocument = new ActiveXObject("Microsoft.XMLDOM"); var xmlDocument = new ActiveXObject("MSXML2.DOMDocument"); // var xmlDocument = new ActiveXObject("MSXML2.DOMDocument.3.0"); xmlDocument.load("news.xml"); var docRoot = xmlDocument.documentElement; if (docRoot == null) alert("Document is null"); else { // Test Node Interface Properties var Name = docRoot.nodeName; var NodeValue = docRoot.nodeValue; var NodeType = docRoot.nodeType; var dt = xmlDocument.doctype; var imp = xmlDocument.implementation; var numChildren = docRoot.childNodes.length; var firstChildName = docRoot.firstChild.nodeName; var firstChildVal = docRoot.firstChild.text; var firstChildType = docRoot.firstChild.nodeType; var lastChildName = docRoot.lastChild.nodeName; var nextSibling = docRoot.firstChild.nextSibling; var prevSibling = nextSibling.previousSibling; var owner = docRoot.ownerDocument; // This call returns a named node map, so you must use the // NamedNodeMap interface to retrieve its values. var attributes = docRoot.firstChild.attributes; alert("Document Node:" + Name + "\nDoctype: " + dt + "\nimplementation: " + imp + "\nNumber of Child Nodes:" + numChildren + "\nFirst child Name:" + firstChildName + "\nFirst child value:" + firstChildVal + "\nFirst child type:" + firstChildType + "\nFirst Child's attributes: " + attributes + "\nSibling of first child:" + nextSibling.nodeName + "\nPrevious Sibling from last call:" + prevSibling.nodeName + "\nLast child value:" + lastChildName + "\nowner document: " + owner); // Test Node Interface and Factory Methods var newElem1 = xmlDocument.createElement("elemA"); var newElem2 = xmlDocument.createElement("elemB"); xmlDocument.documentElement.insertBefore(newElem1, docRoot.firstChild); xmlDocument.documentElement.removeChild(docRoot.lastChild); xmlDocument.documentElement.appendChild(newElem2); // Depending upon permissions, this call may or may not work. If // you receive a file permissions error, // rename this file with a .hta // file extension and rerun. xmlDocument.save("test1.xml"); } // else } // Parse </SCRIPT> </BODY> </HTML>