XML Basic
XML HOMEXML Introduction
XML How to use
XML Tree
XML Syntax
XML Elements
XML Attributes
XML Validation
XML Validator
XML Viewing
XML CSS
XML XSLT
XML JavaScript
XML HTTP RequestXML Parser
XML DOM
XML to HTML
XML Applications
XML Advanced
XML NamespacesXML CDATA
XML Encoding
XML Server
XML DOM Advanced
XML Don't
XML Technologies
XML in Real Life
XML Editors
XML Summary
XML Examples
XML ExamplesXML Quiz
XML Certificate
XML DOM
| « Previous | Next Chapter » |
A DOM (Document Object Model) defines a standard way for accessing and manipulating documents.
The XML DOM
The XML DOM defines a standard way for accessing and manipulating XML documents.
The XML DOM views an XML document as a tree-structure.
All elements can be accessed through the DOM tree. Their content (text and attributes) can be modified or deleted, and new elements can be created. The elements, their text, and their attributes are all known as nodes.
You can learn more about the XML DOM in our XML DOM tutorial.
The HTML DOM
The HTML DOM defines a standard way for accessing and manipulating HTML documents.
All HTML elements can be accessed through the HTML DOM.
You can learn more about the HTML DOM in our HTML DOM tutorial.
Load an XML File - Cross browser Example
The following example parses an XML document ("note.xml") into an XML DOM object, and then extract some info from it with a JavaScript:
Example
Try it yourself » |
Important Note!
To extract the text "Tove" from the <to> element in the XML file above ("note.xml"), the syntax is:
| getElementsByTagName("to")[0].childNodes[0].nodeValue |
Notice that even if the XML file contains only ONE <to> element you still have to specify the array index [0]. This is because the getElementsByTagName() method returns an array.
Load an XML String - Cross browser Example
The following example parses an XML string into an XML DOM object, and then extract some info from it with a JavaScript:
Example
Try it yourself » |
| « Previous | Next Chapter » |
