module to create python object representation from xml

I'm searching for an easy to handle python native module to create python object representation from xml.

I found several modules via google (one of them is XMLObject) but didn't want to try out all of them.

What do you think is the best way to do such things?

EDIT: I missed to mention that the XML I'd like to read is not generated by me. It's an existing XML file in a structure of which I have no control over.

Answers


You say you want an object representation, which I would interpret to mean that nodes become objects, and the attributes and children of the node are represented as attributes of the object (possibly according to some Schema). This is what XMLObject does, I believe.

There are some packages that I know of. 4Suite includes some tools to do this, and I believe Amara specifically implements this (built on top of 4Suite). You can also use lxml.objectify, which was inspired by Amara and gnosis.xml.objectify.

Of course a third option is, given a concrete representation of the XML (using ElementTree or lxml) you can build your own custom model around that. lxml.html is an example of that, extending the base interface of lxml with some HTML-specific functionality.


Need Your Help

bootstrap modal opens 2nd modal confirm before delete

javascript jquery twitter-bootstrap confirm bootstrap-modal

I have been trying to get this working for some hours now, but I am having trouble, so I really do need some help.