Comparing the Two Approaches to Parsing XML
The approach to parsing that I have described so far involves building a parse tree, which is the approach that is used in nearly all validating parsers. As you have seen, this method approaches the document as a series of interrelated objects that just happen to have textual content. In the second approach, the parser just treats the document as a flat structure or a text document.
Let's parse the same document by using both methods, and then compare the two.
Parsing a Document as a Tree
This section shows how a parser that creates a document tree might proceed. Pseudocode has been used. (Of course, the process will be a little more complex than this, but this illustrates the general principles employed.) ...
Get XML Unleashed 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.