Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

XML DOM instance


May 28, 2021 XML DOM




XML DOM resolution

The following example uses the XML file .xml.

Load an XML file
Load an XML string

The instance explanation


XML DOM properties and methods

The following example uses the XML file .xml.
The function loadXMLDoc(), in external JavaScript, is used to load XML files.
The function loadXMLString(), in external JavaScript, is used to load XML strings.

Load and resolve XML files - external parsing scripts
Load and parse XML strings - external parsing scripts

The instance explanation


XML DOM access nodes

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

Access the node using the index number in the node list
Loop through the nodes using the length property
View the node type of the element
Loop through element nodes
Use node relationships to loop through element nodes

The instance explanation


XML DOM node information

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

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

The instance explanation


XML DOM node list and property list

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

Get the text from the first element
Loop through the nodes using the length property
Gets the properties of the element

The instance explanation


XML DOM traverses the node tree

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

Traverse the node tree

The instance explanation


XML DOM browser differences

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

Show the length of the list of nodes - IE and other browsers for different results
Ignore empty text between nodes

The instance explanation


XML DOM navigation node

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

Gets the parent node of the node
Gets the first child element of the node
Gets the last child element of the node
Gets the next peer element of the node
Gets the last peer element of the node

The instance explanation


XML DOM gets the node value

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

Gets the text value of the element
Gets the text value of the property

The instance explanation


XML DOM changes the node value

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

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

The instance explanation


XML DOM deletes the node

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

Remove the element node
Delete the current element node
Delete the text node
Empty the text of the text node
Remove properties by name
Delete properties by object

The instance explanation


XML DOM replaces the node

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

Replace the element node
Replace the data in the text node

The instance explanation


XML DOM creates nodes

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

Create an element node
Create property nodes using createAttribute
Create a property node with setAttribute
Create a text node
Create a CDATA segment node
Create a comment node

The instance explanation


XML DOM adds nodes

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

Add a node after the last child node
Add a node before specifying a child node
Add a new property
Add data to the text node

The instance explanation


XML DOM clone node

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

Copy a node and append it to an existing node

The instance explanation


XML DOM XMLHttpRequest object

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

Retrieving header information via getAllResponseHeaders().
Retrieving the header information for the resource (file).

Retrieving the specified header information via getResponseHeader().
Retrieves the specified header information for the resource (file).

Retrieve the contents of the ASP file
How a Web page communicates with a Web server when a user types characters in an input field.

Retrieving content from the database
How a Web page extracts information from a database through the XMLHttpRequest object.

Retrieve the contents of the XML file
Create an XMLHttpRequest to retrieve data from an XML file and display the data in an HTML table.

The instance explanation