Home arrow Python arrow Page 4 - Parsing XML with SAX and Python

Homework&toc - Python

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

  1. Parsing XML with SAX and Python
  2. The xml.sax Package
  3. Our SAX Parser
  4. Homework
  5. Conclusion
By: Nadia Poulou
Rating: starstarstarstarstar / 16
January 21, 2003

print this article


Even if your knowledge of XML and Python is not advanced I hope that by now you got an idea on how to implement a simple XML parser in Python. Of course this was just a very simple example to illustrate the possibilities of the xml.sax module of Python.

Here follow some ideas, based on our example, for further exploration:
  • Try to load the <select> list on our web form dynamically from the XML document; that is to parse the document and to present the player names found as elements of the list.
  • In our example we mentioned nothing about proper XML syntax and similar matters. In production applications things do not always turn out as we would hope. This is why exception handling should always be part of your application. You can try to use one or more exception classes to handle the behaviour of your script as soon as an error occurs, by –for example- showing the appropriate error message.

>>> More Python Articles          >>> More By Nadia Poulou

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Python Big Data Company Gets DARPA Funding
- Python 32 Now Available
- Final Alpha for Python 3.2 is Released
- Python 3.1: String Formatting
- Python 3.1: Strings and Quotes
- Python 3.1: Programming Basics and Strings
- Tuples and Other Python Object Types
- The Dictionary Python Object Type
- String and List Python Object Types
- Introducing Python Object Types
- Mobile Programming using PyS60: Advanced UI ...
- Nested Functions in Python
- Python Parameters, Functions and Arguments
- Python Statements and Functions
- Statements and Iterators in Python

Developer Shed Affiliates


Dev Shed Tutorial Topics: