DOM

In this chapter you will learn:

  1. What is DOM

What is DOM

DOM stands for document object model. The Document Object Model (DOM) is a cross-platform and language-independent. DOM is a convention for representing and interacting with objects in XML documents.

A DOM parser loads the entire document into a memory tree structure so that the nodes of the tree can be randomly accessed. The nodes are all linked together in parent/child relationships that are representative of the relationships in the original document.

Each tree node in the parsed DOM tree represents an DOM object. The following table lists objects that make up the parse tree.

Name Description
Attr An attribute consisting of a name and a value to be associated with the name.
CDATASection A block of text in an escape format.
Comment The text of a comment.
Document The root node of the entire document tree.
DocumentFragment A lightweight form of Document.
DocumentType The node in the tree that contains descriptive information about the format of the elements.
Element A tag used to mark up a section of text.
Entity An entity, either parsed or unparsed.
EntityReference An unexpanded entity.
Notation A notation declared as part of the DTD or schema.
ProcessingInstruction A processing instruction is a processor-specific instruction included in the document.
Text Character data.

Next chapter...

What you will learn in the next chapter:

  1. How to parse an XML String
Home » Java Tutorial » XML

DOM Parser

    DOM
    Parse XML string
    Parse XML file with DOM Parser
    DOM Parser Error
    Output DOM Document to console
    Save DOM Document to a file
    Format a DOM Document
    Output Document to String
    Visit all elements
    Element retrieve by tag name
    Element character data retrieve
    DOM node visiting
    Node type
    DOM node dump
    Children nodes
    Root Element
    Doc Type
    Declared Entities
    External Entities resolve
    DOMImplementation

DOM Edit

    Element text child data
    Element remove
    Add text node to element
    Element text data update
    Add attribute to element
    Attribute remove
    Create new empty element
    Element clone
    CDATASection
    Comments element
    Processing Instruction
    New XML Document

SAX Parser

    SAX Parser action
    Parse an XML file with SAX parser
    SAX Parser based XML Document dump
    SAX Parser Error Handler
    SAX Parser content handler
    SAX Locator

Utility

    Encode String for XML attribute
    Convert Source to InputSource