DOM is a read-write API. DOM documents are created not only by parsing text files, but also by creating new documents in memory out of nothing at all. These documents can then be serialized onto a stream or into a file. The abstract factory interface that creates new Document objects is called DOMImplementation . The Document interface has a dual purpose: First, it represents XML documents themselves and provides access to their contents, document type declaration, and other properties. Second, it too is an abstract factory responsible for creating the nodes that go in the document: elements, text, comments, processing instructions, and so on. Each such node belongs exclusively to the document that created it and cannot be moved to a different document. |