Tutorial – XML Programming in JavaSection 2 – Parser basics3
Section 2 – Parser basics
An XML parser is a piece of code that reads adocument and analyzes its structure. In thissection, we’ll discuss how to use an XML parser toread an XML document. We’ll also discuss thedifferent types of parsers and when you might wantto use them.Later sections of the tutorial will discuss what you’llget back from the parser and how to use thoseresults.
How to use a parser
We’ll talk about this in more detail in the followingsections, but in general, here’s how you use aparser:1. Create a parser object2. Pass your XML document to the parser 3. Process the resultsBuilding an XML application is obviously moreinvolved than this, but this is the typical flow of anXML application.
Kinds of parsers
There are several different ways to categorizeparsers:
Validating versus non-validating parsers
Parsers that support the Document ObjectModel (DOM)
Parsers that support the Simple API for XML(SAX)
Parsers written in a particular language (Java,C++, Perl, etc.)