Introduction to DOM Parsers

You can use a DOM parser to process XML documents at runtime. A DOM parser reads an entire XML document and creates a hierarchical tree-based structure called a DOM tree. The DOM tree contains objects that represent the content of XML documents, such as elements, attributes, or comments. For example, the graphic shows the DOM tree after parsing the following XML document:

   <Department>
       <Employee>
          <Name>Name1</Name>
          <Email>Name1@example.com</Email>
       </Employee>
       <Employee>
          <Name>Name2</Name>
          <Email>Name2@example.com</Email>
       </Employee>
   </Department>


You can manipulate the DOM tree using various methods defined in the DOM API specifications. For example, the following method provides the root element of an XML document:

   getDocumentElement()

The graphic shows a DOM tree, which contains objects that represent the content of XML documents, such as elements, attributes, or comments.
Click the Next button to continue.