XML DOM
DOM (Document Object Model) defines the standard methods for accessing and manipulating documents.
XML DOM
XML DOM (XML Document Object Model) defines the standard methods for accessing and manipulating XML documents.
XML DOM views XML documents as tree structures.
All elements can be accessed through the DOM tree. They can be modified or deleted, and new elements can be created. Elements, their text, and their attributes are considered nodes.
In our XML DOM Tutorial, you can learn more about XML DOM.
HTML DOM
HTML DOM defines the standard methods for accessing and manipulating HTML documents.
All HTML elements can be accessed through the HTML DOM.
In our HTML DOM Tutorial, you can learn more about HTML DOM.
Loading an XML File - Cross-Browser Example
The following example parses the XML document ("note.xml") into an XML DOM object, and then extracts some information through JavaScript:
Example
Important Note!
To extract the text "Tove" from the <to>
element in the XML file ("note.xml"), the syntax is:
Note that even if the XML file contains only one <to>
element, you still need to specify the array index [0]. This is because the getElementsByTagName() method returns an array.
Loading an XML String - Cross-Browser Example
The following example parses the XML string into an XML DOM object, and then extracts some information through JavaScript: