This tool rules! Using it, you can suck some XML (or XHTML!) into a DOM object, then access the DOM object with normal Python object syntax. For example, to parse some xhtml and look at at a form's input element and its attributes, you could do something like:
from xml_objectify import XML_Objectify
dom = XML_Objectify("somefile.xhtml").make_instance()
inputElement = dom.body.form.div.table.tr[4].td[0].input
print inputElement.type
print inputElement.name
print inputElement.valueThis short example might not give a sense of how useful this is- this way is very Pythonic, and the other ways of accessing XML through Python DOM tools (xml.dom.minidom, etc.) are pretty cumbersome. This saves a lot of time, a lot of wasted thought cycles since it works the way you expect it to, and it's terse too.
There is an article about XML Objectify here: http://www-106.ibm.com/developerworks/xml/library/xml-matters2/index.html
Thank you, David Mertz!
We made a patch to xml_objectify.py to allow use of StringIO objects as well as files or file objects. Here's the patch:
203c203 < elif type(file) == FileType: --- > elif (type(file) == FileType) or (file.__class__.__name__ == 'StringIO'):
-AdamFeuer (with help from Paul Dupuy and Troy Frever)
The current (2003-02-13) distribution of XMLObjectify can be found at http://gnosis.cx/download/Gnosis_Utils-current.tar.gz. This includes a number of David Mertz's modules, and he recommends downloading that distribution instead of just the XMLObjectify package.
Note that in the current distribution of XMLObjectify, the import statement
from xml_objectify import XML_Objectify
should be replaced by
from gnosis.xml.objectify import XML_Objectify
and the module xml_objectify no longer exists under that name, so I don't know about the patch above.