PDOM (Partial DOM) is a open source XML Parser which is positioned in between SAX and DOM.

SAX, as we know is tedious to program to and DOM loads the entire xml into memory.

PDOM Parser, would load only that section of xml which is required and returns a tree structure similar to that of DOM. (PDOM internally uses SAX).

So how does PDOM Work?

PDOM Parser takes a list of XPATH expressions as input. So construct a XPATH expression for each of the sections of the xml you need and pass it as input to the Parser.

The parser would return a Map on completion of parsing. The Map would contain the input XPATH as a key and the list of JDOM elements as a value. (JDOM representation is used as it is widely accepted).

This parser would be extremely handy, if you want to traverse through only a small section of a huge XML Document.

HOW PDOM Works internally?

PDOM internally has a built in XPATH compiler which would compile and interpret the xpath expressions. There are three blocks which form the core of PDOM Parser:

1. Locator - Locates the right elements in the xml which are represented by the xpath.

2. Collector  - Collects the specified elements into a JDOM element.

3. Filter - Filter is invoked at the end of parsing. It verifies if each of the element collected is valid after running the expression evaluator.

For more information on PDOM Parser refer to :