The data read from an XML file is arranged in Internet Explorer's memory as an object called DOMDocument. The DOMDocument object has 35 properties, 25 methods, and three events.
With this object, you can load XML files, navigate the document graph model and query nodes of the graph. The first thing you need to do is create an empty object, which you can accomplish with the ActiveXObject creator:
xmldoc = new ActiveXObject("Msxml2.DOMDocument.3.0");
Now you can load the XML file with the load() method:
xmldoc.load("mydvd.xml");
The following script loads an XML file and prints its content to an alert box. Try it in Internet Explorer. You should get the XML file echoed back in an alert box.
<SCRIPT LANGUAGE="JavaScript">
<!--
var xmldoc=new ActiveXObject("MSXML2.DOMDocument.3.0");
xmldoc.load("mydvd.xml");
alert(xmldoc.documentElement.xml);
// -->
</SCRIPT>
Do you have comments on this tip? Let us know.
Related information from SearchDomino.com:
Requires Free Membership to View
Register today to access targeted resources from our editorial writers and independent industry experts focused on Lotus Domino, Notes, Workplace and other related technologies.
- Markup Language
- Learning Guide: JavaScript
- Tip: Transferring Domino information to JavaScript
- Reference Center: JavaScript tips and resources
- Reference Center: XML/Web services tips and resources
This tip was submitted to the SearchDomino.com tip library by member Chandra Teja. Please let others know how useful it is via the rating scale below. Do you have a useful Lotus Notes, Domino, Workplace or WebSphere tip or code snippet to share? Submit it to our monthly tip contest and you could win a prize.
This was first published in February 2007