Latest web development tutorials

XML DOM Examples

XML DOM parsing

The following example uses XML files the Books.xml .

Loading an XML file
Loading an XML string

Examples explained


XML DOM Properties and Methods

The following example uses XML files the Books.xml .
Function loadXMLDoc () , in an external JavaScript is used to load the XML file.
Function loadXMLString () , in an external JavaScript is used to load the XML string.

Load and parse the XML file - external parsed script
Load and parse the XML string - external parsed script

Examples explained


XML DOM node access

The following example uses XML files the Books.xml .
Function loadXMLDoc () , in an external JavaScript is used to load the XML file.

Use the node list of access nodes index number
Loop through nodes using the length property
View node type element
Loop through element nodes
Use loop through element nodes Node Relationship

Examples explained


XML DOM node information

The following example uses XML files the Books.xml .
Function loadXMLDoc () , in an external JavaScript is used to load the XML file.

Get the name of the node element node
Get text from text node
Change the text node
Gets the element node with name and type

Examples explained


XML DOM node lists and property lists

The following example uses XML files the Books.xml .
Function loadXMLDoc () , in an external JavaScript is used to load the XML file.

Get the text from the first <title> element
Loop through nodes using the length property
Get element attributes

Examples explained


XML DOM node tree traversal

The following example uses XML files the Books.xml .
Function loadXMLString () , in an external JavaScript is used to load the XML string.

Traversing the node tree

Examples explained


XML DOM Browser Differences

The following example uses XML files the Books.xml .
Function loadXMLDoc () , in an external JavaScript is used to load the XML file.

The length of the display node list - different outcomes IE and other browsers
Between empty text nodes ignored

Examples explained


XML DOM node navigation

The following example uses XML files the Books.xml .
Function loadXMLDoc () , in an external JavaScript is used to load the XML file.

Being the parent of a node
Get the first child node
Get the last child node of the element
Get the next sibling element node
Get on a sibling element node

Examples explained


Get XML DOM node value

The following example uses XML files the Books.xml .
Function loadXMLDoc () , in an external JavaScript is used to load the XML file.

Get the text value of the element
Get text property value

Examples explained


XML DOM node values change

The following example uses XML files the Books.xml .
Function loadXMLDoc () , in an external JavaScript is used to load the XML file.

Change text node element
Use setAttribute to change the property value
Change the property value using nodeValue

Examples explained


XML DOM delete nodes

The following example uses XML files the Books.xml .
Function loadXMLDoc () , in an external JavaScript is used to load the XML file.

Remove the element node
Remove the current element node
Delete text node
Clear text node
Delete attribute by name
Press the Delete Object Properties

Examples explained


XML DOM replacement node

The following example uses XML files the Books.xml .
Function loadXMLDoc () , in an external JavaScript is used to load the XML file.

Replace element node
Data replacement text node

Examples explained


Create XML DOM node

The following example uses XML files the Books.xml .
Function loadXMLDoc () , in an external JavaScript is used to load the XML file.

Create an element node
Create an attribute node using createAttribute
Create an attribute node using setAttribute
Create a text node
Create a CDATA section node
Create a comment node

Examples explained


Adding XML DOM node

The following example uses XML files the Books.xml .
Function loadXMLDoc () , in an external JavaScript is used to load the XML file.

After the last child node to add a node
Before specified child node to add a node
Adding a new property
Add data to a text node

Examples explained


XML DOM node cloning

The following example uses XML files the Books.xml .
Function loadXMLDoc () , in an external JavaScript is used to load the XML file.

Copy a node and append it to an existing node

Examples explained


XML DOM XMLHttpRequest Object

A simple instance of XMLHttpRequest
Create a simple XMLHttpRequest, and retrieve data from a TXT file.

By getAllResponseHeaders () to retrieve header information
To retrieve the resource (document) header information.

Header information specified by the getResponseHeader () retrieves
To retrieve the resource (file) to specify the header information.

Content retrieval ASP file
When the user types characters in the input field, how Web pages communicate with the Web server.

Retrieved from the database content
Web page how to extract information from the database through the XMLHttpRequest object.

Content retrieval XML file
Create an XMLHttpRequest to retrieve data from the XML file and display the data in an HTML table.

Examples explained