Skip to main content

An etree utility package

Project description

dynamicxml

A simple extension of Etree that gives users the ability to directly access attributes and nodes without having to implement boilerplate python code.

Rationale for this library: Dynamic XML Library with Python

Pip Installer: pip

python -m pip install dynamicxml

DynamicElement is a drop-in replacement for any Etree code that you already have

<!-- ConfigFile.xml -->
<ConfigurationData>
    <Runtime timeout="1000" runtimeDataPath="/path/to/runtime/data" />
</ConfigurationData>
# main.py
import dynamicxml

# parse the data and get back an instance of DynamicElement
root = dynamicxml.parse('data/ConfigFile.xml')

# Print the tag of the root element, just like you would a typical etree
# element
print (root.tag)

# get access to the runtime data node, which is a child of
# <ConfigurationData />.  The library returns a list of child
# nodes, regardless of how many elements there are.  An "AttributeError"
# is raised if the node does not exist.
runtimeNode = root.Runtime[0]

# Access the attributes of the node directly using the "attr_" prefix.
print (runtimeNode.attr_timeout)
print (runtimeNode.attr_runtimeDataPath)

# set the data directly
runtimeNode.attr_timeout = str(int(runtimeNode.attr_timeout) + 1)

# easy writing of the data
dynamicxml.write('data/ConfigFile_Updated.xml', root)

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dynamicxml-1.2-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file dynamicxml-1.2-py3-none-any.whl.

File metadata

  • Download URL: dynamicxml-1.2-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.0+

File hashes

Hashes for dynamicxml-1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 edc96329e07f26d014fc9bdd0e62ac69830d146a8eaf5399d8f4143fed4b7abf
MD5 bf08e121da99f8500d805fc9ea9168f1
BLAKE2b-256 3041b60d80b30203fae9505cf3957dfb78f0bde9443d47497590c10bca402aec

See more details on using hashes here.

Supported by

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