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"?>
<article>
  <p>Pre <b>Bold</b> Post</p>
</article>
>>> 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
<article>
  <p>Plain Text vs <b>Bold</b></p>
</article>

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

>>> import nodetree
>>> s = nodetree.Stream('<stream:stream xmlns="jabber:client" ' +
                        'xmlns:stream="http://etherx.jabber.org/streams">')
>>> s.send('<message><body>Hello, World!</body></message>')
>>> s.root.pop(0)
<message>
  <body>Hello, World!</body>
</message>
>>> 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)
<message>
  <body>This works well</body>
</message>

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

Project details


Download files

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

Source Distribution

NodeTree-0.3.tar.bz2 (32.4 kB view details)

Uploaded Source

File details

Details for the file NodeTree-0.3.tar.bz2.

File metadata

  • Download URL: NodeTree-0.3.tar.bz2
  • Upload date:
  • Size: 32.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for NodeTree-0.3.tar.bz2
Algorithm Hash digest
SHA256 51bdb3e436fce84299c085e49343041553a8d699810a658a9c7857bf1486b0d7
MD5 b79443078965a8bc082082b273336093
BLAKE2b-256 1837c38682a06471e3e2e819f8746a819edd90d45ef028c13964eae3b42c2ad9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page