Friday, 17 October 2014

DOM Parser


DOM stands for Document Object Model, it represents XML document as a tree of node objects. A DOM parser creates a tree structure in memory from the input xml document and then waits for requests from client.

books.xml
<?xml version="1.0"?>
<books>
 <book>
  <name>Let Us C</name>
  <author>Yashwant Kanetkar</author>
  <price>245.00</price>  
 </book>
</books>



As shown in the above figure, books.xml file is the input for DOM parser. DOM parser takes the input file and makes a tree kind of structure.

Below are the points you should note on DOM parser
1.   DOM tress is constructed before you access the nodes or contents in xml document using DOM parser.
2.   Since tree is constructed by DOM, you can access the nodes in the tree in random order.
3.   For large documents (For ex: 1GB), DOM parser is not a good solution, since it consumes all your memory in tree construction.
4.   By using DOM parser you can manipulate the content of XMl document.


Prevoius                                                 Next                                                 Home

No comments:

Post a Comment