Skip to main content

Pythonic XML Data Binding Package

Project description

NodeTree provides a clean, modern API for working with XML in Python.

Version 0.3 adds support for XML document parsing:

>>> import nodetree
>>> d = nodetree.Document('<article><p>Pre <b>Bold</b> Post</p></article>')
>>> d
<?xml version="1.0"?>
  <p>Pre <b>Bold</b> Post</p>
>>> str(d.root)
'<?xml version="1.0"?>\n<article><p>Pre <b>Bold</b> Post</p></article>\n'
>>> d.root[0]
<p>Pre <b>Bold</b> Post</p>
>>> d.root[0].pop()
' Post'
>>> d.root[0][0] = 'Plain Text vs '
>>> d.root
  <p>Plain Text vs <b>Bold</b></p>

XML streams (eg, XMPP) are also now supported with progressive parsing:

>>> import nodetree
>>> s = nodetree.Stream('<stream:stream xmlns="jabber:client" ' +
>>> s.send('<message><body>Hello, World!</body></message>')
>>> s.root.pop(0)
  <body>Hello, World!</body>
>>> s.send('<message><body>This works')
>>> s.root.pop(0)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: incomplete branch
>>> s.send(' well</body></message>')
>>> s.root.pop(0)
  <body>This works well</body>

This release also adds support for ProcessingInstruction nodes and fixes several bugs regarding XML branch splicing and merging.


NodeTree is still in early development; this release lacks several basic features and contains known bugs which may render it unsuitable for many applications. Notably, there is currently no access to XML namespaces from Python and no support for CDATA nodes, XPath, or XSLT.

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 NodeTree, version 0.3
Filename, size File type Python version Upload date Hashes
Filename, size NodeTree-0.3.tar.bz2 (32.4 kB) File type Source Python version None Upload date Hashes View

Supported by

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