XML DOM Examples
XML DOM Parsing
The following example uses the XML file books.xml.
Load an XML File
Load an XML String
XML DOM Properties and Methods
The following example uses the XML file books.xml.
function loadXMLDoc(), in external JavaScript, used to load an XML file.
function loadXMLString(), in external JavaScript, used to load an XML string.
Load and parse an XML file - External parsing script
Load and parse an XML string - External parsing script
XML DOM Accessing Nodes
The following example uses the XML file books.xml.
function loadXMLDoc(), in external JavaScript, used to load an XML file.
Access nodes using index numbers in a node list
Loop through nodes using the length property
Check the node type of an element
Loop through element nodes
Loop through element nodes using node relationships
XML DOM Node Information
The following example uses the XML file books.xml.
function loadXMLDoc(), in external JavaScript, used to load an XML file.
Get an Element Node's Node Name
Get Text from a Text Node
Change the text of a text node
Get the node name and type of an element node
XML DOM Node Lists and Attribute Lists
The following example uses the XML file books.xml.
function loadXMLDoc(), in external JavaScript, used to load an XML file.
From the first
Use the length property to loop through the nodes
Get the attributes of an element
XML DOM Traverse the Node Tree
The following example uses the XML file books.xml.
Function loadXMLString(), in external JavaScript, used to load an XML string.
XML DOM Browser Differences
The following example uses the XML file books.xml.
Function loadXMLDoc(), in external JavaScript, used to load an XML file.
Display the length of the node list - different results in IE and other browsers
ignore empty text between nodes
XML DOM Navigate Nodes
The following example uses the XML file books.xml.
Function loadXMLDoc(), in external JavaScript, used to load an XML file.
Get the parent node of a node
Get the first child element of a node
Get the last child element of a node
Get the next sibling element of a node
Get the previous sibling element of a node
XML DOM Get a Node Value
The following example uses the XML file books.xml.
Function loadXMLDoc(), in external JavaScript, used to load an XML file.
Get the text value of an element
Get the text value of an attribute
XML DOM Change a Node Value
The following example uses the XML file books.xml.
Function loadXMLDoc(), in external JavaScript, used to load an XML file.
Change an element's text node
Use setAttribute to change an attribute value
Use nodeValue to change an attribute value
XML DOM Remove a Node
The following example uses the XML file books.xml.
Function loadXMLDoc(), in external JavaScript, used to load an XML file.
Delete an element node
Delete the current element node
Delete a text node
Clear the text of the text node
Remove an attribute by name
Remove an attribute by object
XML DOM Replace a Node
The following example uses the XML file books.xml.
Function loadXMLDoc(), in external JavaScript, used to load an XML file.
Replace an element node
Replace the data in a text node
XML DOM Create a Node
The following example uses the XML file books.xml.
Function loadXMLDoc(), in external JavaScript, used to load an XML file.
Create an element node
Use createAttribute to create an attribute node
Use setAttribute to create an attribute node
Create a text node
Create a CDATA section node
Create a comment node
XML DOM Add a Node
The following example uses the XML file books.xml.
Function loadXMLDoc(), in external JavaScript, used to load an XML file.
Add a node after the last child node
Add a node before the specified child node
Add a new attribute
Add data to a text node
XML DOM Clone a Node
The following example uses the XML file books.xml.
function loadXMLDoc(), in external JavaScript, used to load an XML file.
Copy a node and append it to an existing node
XML DOM XMLHttpRequest Object
A simple XMLHttpRequest example
Create a simple XMLHttpRequest and retrieve data from a TXT file.
Retrieve header information with getAllResponseHeaders()
Retrieve the header information of a resource (file).
Retrieve specified header information with getResponseHeader()
Retrieve a specified header of a resource (file).
Retrieve the content of an ASP file
How a web page communicates with a web server when a user types characters into an input field.
Retrieve content from a database
How a web page extracts information from a database through the XMLHttpRequest object.
Retrieve the content of an XML file
Create an XMLHttpRequest to retrieve data from an XML file and display the data in an HTML table.