Manage Learn to apply best practices and optimize your operations.

Loading XML from JavaScript

SearchDomino.com member Chandra Teja explains how to load XML from JavaScript and manipulate the data in Internet Explorer using the DOMDocument object.

When creating and consuming Web services in Internet Explorer, you need to be familiar with operations in Extensible Markup Language (XML). Specifically, you have to know how to load an XML file from JavaScript and manipulate the data loaded into the Web browser.

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:

  • Learning Guide: Extensible 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 last published in February 2007

    Dig Deeper on JavaScript for Lotus Notes Domino

    Start the conversation

    Send me notifications when other members comment.

    By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

    Please create a username to comment.

    -ADS BY GOOGLE

    SearchWindowsServer

    Search400

    • iSeries tutorials

      Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

    • V6R1 upgrade planning checklist

      When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

    • Connecting multiple iSeries systems through DDM

      Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

    SearchDataCenter

    SearchExchange

    SearchContentManagement

    Close