Parsing XML with lxml.objectify

The lxml module has a module called objectify that can turn XML documents into Python objects. I find “objectified” XML documents very easy to work with and I hope you will too. You may need to jump through a hoop or two to install it as pip doesn’t work with lxml on Windows. Be sure to go to the Python Package index and look for a version that’s been made for your version of Python. Also note that the latest pre-built installer for lxml only supports Python 3.2 (at the time of writing), so if you have a newer version of Python, you may have some difficulty getting lxml installed for your version.

Anyway, once you have it installed, we can start going over this wonderful piece of XML again:

Get hands-on with 1200+ tech skills courses.