Implementing a DOM

The DOM has an object design that assumes the use of object-oriented programming and scripting languages, such as C++, Java and JavaScript. The following examples are all Java code fragments, but the principles are the same for other languages.

The DOM standard is composed of a number of interfaces. In Java, these interfaces are defined in the package org.w3c.dom. Typically, a parser developer will implement these interfaces, and replace them with classes that have the same names. The application developer then only needs to import this package and use these classes. The following examples assume this scenario.

There are some important activities involved in parsing, navigating and processing documents that the DOM standard ...

Get XML Companion, The, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.