XML DOM Examples
XML DOM Parsing
The XML file used in the examples below: note.xml
Parse an XML file - Crossbrowser example
Parse an XML string - Crossbrowser example
Examples explained
XML DOM Traversing Nodes
The XML file used in the examples below: note.xml
Traverse a node tree
Examples explained
XML DOM Get Nodes
In the examples below, we will use the XML file
books.xml, and the JavaScript function
loadXMLDoc().
Use
getElementsbyTagname()
Use
getAttribute()
Use
getNamedItem()
Examples explained
XML DOM Set Nodes
In the examples below, we will use the XML file
books.xml, and the JavaScript function
loadXMLDoc().
Set a new attribute and attribute value
Create a new attribute node
Change an attribute's value
Change an item's value
Examples explained
XML DOM Remove Nodes
In the examples below, we will use the XML file
books.xml, and the JavaScript function
loadXMLDoc().
Remove an element
Remove text from a text node
Remove an attribute
Use removeAttributeNode()
Examples explained
XML DOM Replace Nodes
In the examples below, we will use the XML file
books.xml, and the JavaScript function
loadXMLDoc().
Replace a node in a nodelist
Replace data in a text node
Examples explained
XML DOM Create Nodes
In the examples below, we will use the XML file
books.xml, and the JavaScript function
loadXMLDoc().
Create an element node
Create an attribute node
Create a text node
Create a CDATA section node
Create a comment node
Examples explained
XML DOM Add Nodes
In the examples below, we will use the XML file
books.xml, and the JavaScript function
loadXMLDoc().
Add a node to the end of a node list
Add a node before a specific node
Set a new attribute and attribute value
Insert data into a text node
Examples explained
XML DOM Clone Nodes
In the examples below, we will use the XML file
books.xml, and the JavaScript function
loadXMLDoc().
Copy a node
and add it to the node list
Examples explained
|