Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

XML DOM Methods

XML DOM - Properties and Methods


Properties and methods define the programming interface for the XML DOM.


Programming Interface

DOM models XML as a series of node objects. Nodes can be accessed through JavaScript or other programming languages. In this tutorial, we use JavaScript.

The programming interface to the DOM is defined through a standard set of properties and methods.

propertyOften used in the way of "what something is" (for example the node name is "book").

MethodOften used in the way of "do something to something" (for example delete the "book" node).


XML DOM Properties

Some typical DOM properties:

Note: In the list above, x is a node object.


XML DOM Methods

Note: In the list above, x is a node object.


Example

from books.xml's element text JavaScript code:</p>

txt=xmlDoc.getElementsByTagName("title")[0].childNodes[0].nodeValue

After this statement is executed, the value stored in txt is "Everyday Italian".

Explanation: