dynamicxml-1.2
توضیحات
An etree utility package
| ویژگی | مقدار |
|---|---|
| سیستم عامل | OS Independent |
| نام فایل | dynamicxml-1.2 |
| نام | dynamicxml |
| نسخه کتابخانه | 1.2 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Clay Brooks |
| ایمیل نویسنده | clay_brooks@outlook.com |
| آدرس صفحه اصلی | https://github.com/claybrooks/dynamic-xml |
| آدرس اینترنتی | https://pypi.org/project/dynamicxml/ |
| مجوز | - |
# 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](https://claybrooks.github.io/python/2021/04/09/python-dynamic-xml.html)
Pip Installer: [pip](https://pypi.org/project/dynamicxml/)
python -m pip install dynamicxml
`DynamicElement` is a drop-in replacement for any Etree code that you already have
```xml
<!-- ConfigFile.xml -->
<ConfigurationData>
<Runtime timeout="1000" runtimeDataPath="/path/to/runtime/data" />
</ConfigurationData>
```
```python
# 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)
```
نحوه نصب
نصب پکیج whl dynamicxml-1.2:
pip install dynamicxml-1.2.whl
نصب پکیج tar.gz dynamicxml-1.2:
pip install dynamicxml-1.2.tar.gz