objectify is a module in the lxml library which enables parsing of XML and HTML documents. Here is an example of how to parse an XML document using objectify in Python:
main.py653 chars24 lines
In this example, we first import the objectify module from lxml. We then define an example XML document as a string.
To parse the XML document, we use the objectify.fromstring() function, which returns a root element object that we can use to access the contents of the XML document.
Finally, we loop through each person element in the document and print out the values of the name and age elements for each person.
gistlibby LogSnag