© Jeff Friesen 2019
Jeff FriesenJava XML and JSONhttps://doi.org/10.1007/978-1-4842-4330-5_3

3. Parsing and Creating XML Documents with DOM

Jeff Friesen1 
(1)
Dauphin, MB, Canada
 

SAX can parse XML documents but cannot create them. In contrast, DOM can parse and create XML documents. Chapter 3 introduces you to DOM.

What Is DOM?

Document Object Model (DOM) is a Java API for parsing an XML document into an in-memory tree of nodes and for creating an XML document from a node tree. After a DOM parser creates a tree, an application uses the DOM API to navigate over and extract infoset items from the tree’s nodes.

DOM has two big advantages over SAX:
  • DOM permits random access to a document’s infoset items, whereas SAX only permits serial access.

  • DOM lets you ...

Get Java XML and JSON: Document Processing for Java SE 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.