REPOST: introduction to xml in python

Alex Martelli aleax at aleax.it
Mon Dec 31 12:11:14 CET 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.  

http://aspn.activestate.com/ASPN/Cookbook/Python?kwd=XML

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:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52256
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65127
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65128
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 
http://www.oreilly.com/catalog/pythonxml/ 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:
http://www.oreilly.com/catalog/pythonxml/chapter/ch01.html
so, be sure to look into it, of course!!!


Alex




More information about the Python-list mailing list