REPOST: introduction to xml in python

Alex Martelli aleax at
Mon Dec 31 06:11:14 EST 2001

Rajarshi Guha wrote:

> Hi,
>   could somebody point me to some code/tutorial describing how to use
> Python to parse XML  - I tried delving into the Python docs, but it seems
> confusing. Whats the difference between expat and sax?  How can I generate
> a parsers etc.

Besides the good suggestions you have already received, I urge you to have 
a look at the XML section of the Python Cookbook, particularly if you learn 
well from examples rather than from theoretical discussion.

Paul Prescod's five recipes out of the 12 this will show are particularly 
instructive, IMHO; Nenadov's shows you how to use expat specifically rather 
than the normal sax interface (which is a more usual choice); others touch 
on perhaps more exoteric themes, but still hint at the breadth of 
applications that Python affords on XML at various levels.  Start, in 
particular, with:
in this order, and you already have a first elementary intro to the subject!

The "paper" version of the Cookbook will (I hope, or I wouldn't be hard at 
work editing it:-) provide added-value, with a chapter introduction (by 
Paul Prescod, again!) framing the whole XML/Python subject, and recipes and 
discussions selected and edited for completeness and readability.  But the 
"raw materials" of the online version have the substantial plus of being 
out there right now.  The already-mentioned is also "out there right now", of 
course, and a huge plus is that the online sample chapter is chapter 1, 
providing an excellent intro & overview:
so, be sure to look into it, of course!!!


More information about the Python-list mailing list