Easy Tutorial
❮ Met Element Haschildnodes Dom Prop Nodelist Length ❯

XML DOM Example


XML DOM Parsing

The following example uses the XML file books.xml.

Load an XML FileLoad an XML String

Example Explanation


XML DOM Properties and Methods

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

Load and Parse XML File - External Parser ScriptLoad and Parse XML String - External Parser Script

Example Explanation


XML DOM Access Nodes

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

Access Nodes Using Index Numbers from Node ListLoop Through Nodes Using the Length PropertyCheck the Node Type of an ElementLoop Through Element NodesLoop Through Element Nodes Using Node Relationships

Example Explanation


XML DOM Node Information

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

Get the Node Name of an Element NodeGet Text from a Text NodeChange Text in a Text NodeGet the Node Name and Type of an Element Node

Example Explanation


XML DOM Node List and Attribute List

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

Get Text from the First <title> ElementLoop Through Nodes Using the Length PropertyGet Attributes of an Element

Example Explanation


XML DOM Traverse Node Tree

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

Traverse the Node Tree

Example Explanation


XML DOM Browser Differences

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

Show the Length of the Node List - Different Results in IE and Other BrowsersIgnore Whitespace Between Nodes

Example Explanation


XML DOM Navigate Nodes

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

Get the Parent Node of a NodeGet the First Child Element of a NodeGet the Last Child Element of a NodeGet the Next Sibling Element of a NodeGet the Previous Sibling Element of a Node

Example Explanation


XML DOM Get Node Value

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

Get the Text Value of an ElementGet the Text Value of an Attribute

Example Explanation


XML DOM Change Node Value

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

Change the Text Node of an ElementChange Attribute Value Using setAttributeChange Attribute Value Using nodeValue

Example Explanation


XML DOM Remove Nodes

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

Remove Element NodesRemove the Current Element NodeRemove Text NodesClear the Text of a Text NodeRemove Attributes by NameRemove Attributes by Object

Example Explanation


XML DOM Replace Nodes

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

Replace Element NodesReplace Data in a Text Node

Example Explanation


XML DOM Create Nodes

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

Create Element NodesCreate Attribute Nodes Using createAttributeCreate Attribute Nodes Using setAttributeCreate Text NodesCreate CDATA Section NodesCreate Comment Nodes

Example Explanation


XML DOM Add Nodes

The following example uses the XML file books.xml. loadXMLDoc(), in an external JavaScript, is used to load the XML file. Add a Node After the Last Child NodeAdd a Node Before a Specified Child NodeAdd a New AttributeAppend Data to a Text Node

Example Explanation


XML DOM Clone Node

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

Clone a Node and Append it to an Existing Node

Example Explanation


XML DOM XMLHttpRequest Object

A Simple XMLHttpRequest Example

Retrieve Header Information with getAllResponseHeaders()

Retrieve Specified Header Information with getResponseHeader()

Retrieve Content of an ASP File

Retrieve Content from a Database

Retrieve Content of an XML File

Example Explanation

❮ Met Element Haschildnodes Dom Prop Nodelist Length ❯