1 / 18

Parsing with DOM using MSXML

Parsing with DOM using MSXML. Kanda Runapongsa ( krunapon@kku.ac.th ) Dept. of Computer Engineering Khon Kaen University. XML DOM. The XML Document Object Model (DOM) is a Programming Interface for XML documents It defines the way an XML document can be accessed and manipulated

eddiev
Download Presentation

Parsing with DOM using MSXML

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Parsing with DOM using MSXML Kanda Runapongsa (krunapon@kku.ac.th) Dept. of Computer Engineering Khon Kaen University

  2. XML DOM • The XML Document Object Model (DOM) is a Programming Interface for XML documents • It defines the way an XML document can be accessed and manipulated • It is designed to be used with several programming languages and any operating system 168493: XML and Web Services (II/2546)

  3. Introduction to DOM • A program called an XML parser can be used to load an XML document into the memory • When the document is loaded, its information can be retrieved and manipulated by accessing the DOM 168493: XML and Web Services (II/2546)

  4. Overview of DOM • The DOM represents a tree view of the XML document • The documentElement is the top-level of the tree • This element has one or many childNodes that represent the branches of the tree 168493: XML and Web Services (II/2546)

  5. The Microsoft XML Parser • Supports JavaScript, VBScript, Perl, VB, Java, C++ and more • Supports W3C XML 1.0, XML DOM, and SAX • Supports DTD and XSD • The Microsoft XML parser is a COM component that comes with Microsoft Internet Explorer 168493: XML and Web Services (II/2546)

  6. Creating an XML Document Object • Javascript • var xmlDoc = new ActiveXObject("Microsoft.XMLDOM") • VBScript • set xmlDoc = CreateObject("Microsoft.XMLDOM") 168493: XML and Web Services (II/2546)

  7. Loading an XML File <script type="text/javascript"> var xmlDoc = new ActiveXObject("Microsoft.XMLDOM") xmlDoc.async="false" xmlDoc.load(“cdcatalog.xml") // ....... processing the document goes here </script> 168493: XML and Web Services (II/2546)

  8. DOM Node • The node object represents a node in the node tree. • A node can be an element node, a text node, or any other of the node types • All of these node types have properties and methods 168493: XML and Web Services (II/2546)

  9. DOM Node Properties 168493: XML and Web Services (II/2546)

  10. DOM Node Properties 168493: XML and Web Services (II/2546)

  11. DOM Node Properties 168493: XML and Web Services (II/2546)

  12. DOM Node Methods 168493: XML and Web Services (II/2546)

  13. DOM Node Methods 168493: XML and Web Services (II/2546)

  14. Node Types 168493: XML and Web Services (II/2546)

  15. Node Types 168493: XML and Web Services (II/2546)

  16. DOM NodeList Object • length: return the number of nodes in a nodeList • item: return a specific node in the nodeList • Examples: • xmlDoc.documentElement.childNodes.length • xmlDoc.documentElement.childNodes.item(2) 168493: XML and Web Services (II/2546)

  17. DOM Elements • tagName: return the tag name of a node • getElementsByTagName: return the value of a specified node • getAttribute: return an attribute’s value 168493: XML and Web Services (II/2546)

  18. DOM Attributes • name: return the name of an attribute • Value: return the value of an attribute • Example: for each x in xmlDoc.documentElement.attributes document.write(x.name) document.write(x.value) next 168493: XML and Web Services (II/2546)

More Related