A simpler XML writer
Project description
XmlElement
A simpler XML writer.
Installation
pip install XmlElement
Test
>>> from XmlElement import XmlElement as X
>>> xml = X.from_string('<test><x/></test>')
>>> xml
XmlElement(test)
Usage
Creating XmlElements
import XmlElement from XmlElement
xml = XmlElement('RootElement', s=[ # root element without attributes
X('Child1', {'name': 'child1', 'testattr': 'Example attribute'}, [ # sub element with an attribute
X('Child2', t='Example text value') # sub-sub element with text value
])
])
Accessing values by dot operator
print(xml)
print(xml.Child1[0].attribute['testattr']) # Example attribute
print(xml.Child1[0].Child2[0].text) # Example text value
Accessing values dict-like (to avoid static type checker warnings)
print(xml)
print(xml['Child1'][0].attribute['testattr']) # Example attribute
print(xml['Child1'][0]['Child2'][0].text) # Example text value
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
XmlElement-0.1.5.tar.gz
(3.3 kB
view hashes)
Built Distribution
Close
Hashes for XmlElement-0.1.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bbbed6ab19310fbeeb9c7ae39cfdf6c7e7c7f59552a60745c32319e848d22eb1 |
|
MD5 | d2605afb88017f6f76c9d48f2495a006 |
|
BLAKE2b-256 | 03d6f399419abca1c9f60ad3cc98ac1e0bbb323be9f7e603dd2af6926b7fc267 |