XML DOM

tutorial and example
tutorial and example

Document object Model (DOM) is foundation of XML. It is tree based information called nodes; it is a way of describing those nodes and the relationship between them. A DOM is said to be tree based. A DOM document is a collection of nodes organized in hierarchy. The hierarchy allows the developers to navigate through the tree to looking for specific information.

In XML DOM it provides an API to developer to add, edit, move or remove nodes in tree at any place in order to create the application.

Example

In above example (sample.html) parses an XML document (“address.html”) into a XML DOM object and then extracts some information from it with JavaScript.

Contents of address.xml

Program execute

Keep these two files sample.htm and address.xml in same directory and execute the sample.html by opening it in browser and see the output.