Chapter 9. The Document Object Model

The Document Object Model, DOM for short, is an abstract data structure that represents XML documents as trees made up of nodes. Various interfaces in the org.w3c.dom package represent elements, attributes, parsed character data, comments, and processing instructions. All of these are subinterfaces of the common Node interface, which provides basic methods for navigating and pruning the tree.

The root of the tree is a Document object that represents a complete, well- formed document. A parser reads an XML document from a stream and builds a Document object representing that XML document. The client program calls the methods of Document and the other DOM interfaces to navigate the tree and extract information from the document. Programs can also manipulate the tree in memory to add, delete, move, or change its nodes. Programs can even create completely new documents from scratch in memory, and these new documents are then written into an XML file.

DOM is defined in the Interface Definition Language (IDL); therefore, it is language neutral. DOM bindings exist for most object-oriented languages, including Java, JavaScript, C++, Python, and Perl. However, since this is a book about Java, I will deal exclusively with the Java implementation.

Processing XML with Java. A Guide to SAX, DOM, JDOM, JAXP, and TrAX
Processing XML with Javaв„ў: A Guide to SAX, DOM, JDOM, JAXP, and TrAX
ISBN: 0201771861
EAN: 2147483647
Year: 2001
Pages: 191 © 2008-2017.
If you may any questions please contact us: