Skip to main content

Dot notation for ElementTrees

Project description

build-status-image pypi-version wheel


Wouldn’t it be nice to use dot notation for ElementTrees? This package allows for:

tree = ET.fromstring('<root><a><b c="asdf" /></a></root>')
a = tree.a
b = a.b
b.attrib['c'] == "asdf" # True

tree.a will be a `Element <>`__ with the extra `__getattr__ <>`__ method. This means that you can use the element as you would do normally, but names in your XML that crases with python’s methods or attributes must be accessed through tree.find(xpath).

This package uses the python implementation of etree, which makes it slower than etree found in CPython. An alternative would be to monkey-patch the built-in with forbiddenfruit, but I haven’t looked into this.

objectifiedetree has copied the python implementation of etree from CPython 3.4 Lib/xml/etree and will probably only work with Python 3.4.


Install using pip

pip install objectifiedetree


from objectifiedetree import *

tree = ET.parse('/path/to/file.xml')
# dot notation :-)
el =

# use normal etree attributes

# access name crashes
attrib_el = el.find('./attrib')


Install dependencies and link development version of objectifiedetree to pip:

git clone
cd objectifiedetree
pip install -r requirements.txt # install dependencies and objectifiedetree-package



Build documentation locally

To build the documentation:

pip install -r docs/requirements.txt
make docs

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for objectifiedetree, version 0.0.1
Filename, size File type Python version Upload date Hashes
Filename, size objectifiedetree-0.0.1-py2.py3-none-any.whl (25.4 kB) File type Wheel Python version 3.4 Upload date Hashes View
Filename, size objectifiedetree-0.0.1.tar.gz (27.6 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page