HOME

XML DOM Tutorial
DOM HOME
DOM Introduction
DOM Parsing
DOM ParseError
DOM Validator
DOM Access
DOM HttpRequest
DOM NodeType

XML DOM Objects
DOM Node
DOM NodeList
DOM Document
DOM Element
DOM Attr
DOM Text
DOM CDATA
DOM Comment

Examples
DOM Examples
Download XMLSpy here
Please visit our sponsors !

Parsing the DOM

prev next

The Microsoft XML parser is a COM component that comes with Microsoft Internet Explorer 5.0. Once you have installed IE 5.0, the parser is available to scripts inside HTML documents and ASP files.


The Microsoft XML Parser

To read and update - create and manipulate - an XML document, you need an XML parser. 

The Microsoft XMLDOM parser features a programming model that:

  • Supports JavaScript, VBScript, Perl, VB, Java, C++ and more
  • Supports W3C XML 1.0 and XML DOM
  • Supports DTD and validation

If you are using JavaScript in IE 5.0, you can create an XML document object with the following code:

var xmlDoc = new ActiveXObject("Microsoft.XMLDOM")

If you are using VBScript you create an XML document object with the following code:

set xmlDoc = CreateObject("Microsoft.XMLDOM")

If you are using VBScript in an Active Server Page (ASP), you can use the following code:

set xmlDoc = Server.CreateObject("Microsoft.XMLDOM")


Loading an XML file into the parser

The following code loads an existing XML document (note.xml) into the XML parser:

<script type="text/javascript">

var xmlDoc = new ActiveXObject("Microsoft.XMLDOM")
xmlDoc.async="false"
xmlDoc.load("note.xml")
// ....... processing the document goes here

</script>

The first line of the script creates an instance of the Microsoft XML parser. The third line tells the parser to load an XML document called note.xml. The second line assures that the parser will halt execution until the document is fully loaded.

JUST TRY IT new


Loading pure XML text into the parser

The following code loads a text string into the XML parser:

<script type="text/javascript">

var text="<note>"
text=text+"<to>Tove</to><from>Jani</from>"
text=text+"<heading>Reminder</heading>"
text=text+"<body>Don't forget me this weekend!</body>"
text=text+"</note>"

var xmlDoc = new ActiveXObject("Microsoft.XMLDOM")
xmlDoc.async="false"
xmlDoc.loadXML(text)
// ....... processing the document goes here

</script>

Note that the "loadXML" method (instead of the "load" method) is used to load a text string.

JUST TRY IT new


prev next

Jump to: Top of Page or HOME or Printer Friendly Printer friendly page


Search W3Schools:


What Others Say About Us

Does the world know about us? Check out these places:

Dogpile Alta Vista MSN Google Excite Lycos Yahoo Ask Jeeves


We Help You For Free. You Can Help Us!


W3Schools is for training only. We do not warrant its correctness or its fitness for use. The risk of using it remains entirely with the user. While using this site, you agree to have read and accepted our terms of use and privacy policy.

Copyright 1999-2002 by Refsnes Data. All Rights Reserved


Validate How we converted to XHTML Validate

ASPHits
Active Server Pages Resource Web Site


Your own Web Site?

Read W3Schools
Hosting Tutorial



$15 Domain Name
Registration
Save $20 / year!



Advertise
at W3Schools

Only 0.5 CPM



SELECTED LINKS

University Online
Master Degree
Bachelor Degree


Web Software

The Future of
Web Development


Jobs and Careers

Web Security
Web Statistics
Web Standards


PARTNERS

W3Schools
TopXML
VisualBuilder
XMLPitstop
DevelopersDex
DevGuru
Programmers Heaven
The Code Project
Tek Tips Forum
ZVON.ORG
TopXML Search