[Tutor] XML

Kent Johnson kent37 at tds.net
Thu Dec 20 22:46:35 CET 2007


Lockhart, Luke wrote:
> Now, the program I'm working on would hypothetically store and read all 
> data as XML, and yes I'm aware of the performance drawbacks and I'm 
> willing to live with them. But I just can't figure out the various 
> libraries that Python uses to read XML, and my friend's code doesn't 
> help much.
> 
> Basically, what I really would like to do, without going into a lot of 
> detail, is be able to read various tags into classes and arrays until 
> the entire file has been read, then remove the file from memory.

Do you want to create your own classes to represent the data or do you 
just want to get some kind of object model? If the latter, take a look 
at ElementTree, it is IMO the best of the included XML packages.
http://docs.python.org/lib/module-xml.etree.ElementTree.html

Kent


More information about the Tutor mailing list