Chapter 9. Processing XML


Python includes several modules that provide most of the tools necessary to parse and process XML documents. Parsing XML files is becoming much more critical as applications adopt the XML standard as the best way to transfer data between applications and systems.

Because there is no way to cover the extent of options Python provides in XML processing, I've chosen to present phrases that demonstrate some common tasks. To provide as broad of coverage as possible, these phrases will use the xml.dom, xml.sax, and xml.parsers.expat modules.

The phrases in this chapter cover concepts of basic XML processing such as loading, navigating, and checking for well-formed documents. They also cover more advanced XML processing such as searches, tag processing, and extracting text.

Note

Many XML processing tasks could be accomplished differently by using different modules. Don't get locked into a specific module for processing the XML data; another module may perform the same task better.


Note

All the phrases in this chapter process the same XML file. The output of that XML file is listed in the output section of the "Loading an XML Document" phrase.




Python Phrasebook(c) Essential Code and Commands
Python Phrasebook
ISBN: 0672329107
EAN: 2147483647
Year: N/A
Pages: 138
Authors: Brad Dayley

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