Chapter Roadmap


Now that we have covered some introductory material in the first two chapters, we're going to discuss XML parser modules. Remember, the purpose of an XML parser is to parse XML data. Why would we want to do that? So that we can extract the important information (that is, the information contained between start and end tags) contained in the XML data.

Note that I'm using the term XML data rather than XML file . That's because XML data can exist in a number of formats ”an actual file stored on a hard disk, data sent across a Transmission Control Protocol (TCP) or User Datagram Protocol (UDP) socket, or in memory as a dynamically generated result of a database query. No matter where the XML data resides, eventually someone will need to parse it.

This chapter focuses on event-driven XML parser modules and how to easily develop Perl programs based on those modules. One of the modules that provides sequential event-driven access to XML data is XML::Parser. Because XML::Parser also incorporates other parsing models, I only demonstrate its stream style mode, which is in fact, the event-driven model. Other parsing models (for example, the DOM or tree-based parsers) are discussed in Chapter 4, "Tree-Based Parser Modules."

I also discuss the SAX (Simple API for XML) standard, which defines a common interface for event-driven parsers. Currently, there are two versions of the SAX standard ”SAX 1 and SAX2. Both versions are discussed, as well as the differences between each of the versions. Several modules exist that conform to each version.

An important module that I discuss that conforms to the SAX1 version is XML::Parser::PerlSAX. The SAX2 modules are listed in the following:

  • XML::SAX::PurePerl

  • XML::SAX::Expat

  • XML::LibXML

  • XML::Xerces

Each module is discussed and I demonstrate how to use SAX as a common interface to these parsers. Finally, I discuss the differences between each module and when to use each module for a particular task.

This chapter focuses on solving problems using the event-driven parser modules. To do this, you'll need to install the following Perl modules:

  • XML::Parser

  • XML::Parser::PerlSAX

  • XML::SAX

  • XML::SAX::PurePerl

  • XML::SAX::Expat

  • XML::NameSpaceSupport (required by XML::SAX::Expat)

  • XML::Xerces

Note

If you have any questions about Perl modules (for example, where to get them, how to install them, and so forth), please refer to Appendix B, "Perl Essentials."




XML and Perl
XML and Perl
ISBN: 0735712891
EAN: 2147483647
Year: 2002
Pages: 145

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net