Questions about parsing XML

Jarek Zgoda jzgoda at gazeta.usun.pl
Sat Aug 7 15:50:24 CEST 2004


Kyle Root <kyleroot at gmail.com> pisze:

> I'm writing a practice program that parses an xml config file, at the 
> moment I'm using expat.  However I don't like some of it's behaviors. 
> For example ParseFile() will parse the *entire* file and I don't want to 
> do that.  I would like to be able to tell it to find such and such a tag 
> and return the cdata it contains, is this at all possible?  If it is how 
> would I handle optional tags?

libxml2 (http://www.xmlsoft.org/) has excellent support for XPath, F.
Lundh's ElementTree also supports some XPath expressions, although it is
built on expat and needs to parse whole XML document.

-- 
Jarek Zgoda
http://jpa.berlios.de/



More information about the Python-list mailing list