Home arrow XML arrow Parsing XML with SAX and Python

Parsing XML with SAX and Python

In this article Nadia explains how to parse an XML document using the SAX API implementation available for Python.

Author Info:
By: Nadia Poulou
Rating: 4 stars4 stars4 stars4 stars4 stars / 56
November 09, 2004
  1. · Parsing XML with SAX and Python
  2. · The xml.sax Package
  3. · Our SAX Parser
  4. · The Heart of the Code
  5. · Element Content
  6. · The Main Code
  7. · Homework

print this article

Parsing XML with SAX and Python
(Page 1 of 7 )

This tutorial will explain how to parse an XML document using the SAX API implementation available for Python. Of course, there is more than one way to parse XML data with Python. In this article we will focus on its built-in SAX module.

You donít have to be an expert in Python or XML in order to follow this article. On the contrary, this is an introduction rather than an in-depth analysis. Of course I assume that you have some basic knowledge of programming and-Ėpreferably--the Python syntax and structures. It will also be nice if you are aware of the basic XML principles and terms.

In the next part of this article, I will describe the SAX classes of Python. Afterwards, I will use an example in order to show how the theory can be applied. In the last parts I will provide some homework and some links that will help you to delve deeper into the subjects introduced in this article.

In any case, if you want to test the code in this tutorial, you will need to install Python 2.1 or later. I donít provide any installation details; if you need them, I would recommend that you check other sources, such as the article Getting Started With Python.

Our example is Web-based, therefore it would be nice if Python were integrated in your Web server, but-Ėof course--you may modify the script to run as a standalone application or in any other way you desire.

By the end of the article, you will be in a position to successfully use Python in order to parse XML documents with the SAX interfaces, but letís first make sure we cover the theory.

blog comments powered by Disqus

- Open XML Finally Supported by MS Office
- XML Features Added to Two Systems
- Using Regions with XSL Formatting Objects
- Using XSL Formatting Objects
- More Schematron Features
- Schematron Patterns and Validation
- Using Schematron
- Datatypes and More in RELAX NG
- Providing Options in RELAX NG
- An Introduction to RELAX NG
- Path, Predicates, and XQuery
- Using Predicates with XQuery
- Navigating Input Documents Using Paths
- XML Basics
- Introduction to XPath

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


© 2003-2019 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials