Comprehensive XML generator for Python
Project description
Project Name
Comprehensive XML generator for Python
Table of Contents
Installation
pip install xml-generator
Usage
Import
from xml_generator.types import XmlNode
Comprehensive parsing
Parse Comprehensive format into an XmlNode object.
node = XmlNode.parse(
{
"name": "node",
"attributes": {"attr1": "value1", "attr2": "value2"},
"body": [
{"name": "child1", "attributes": {"attr1": "value1"}},
{"name": "child2", "attributes": {"attr2": "value2"}},
],
}
)
Parse Comprehensive format with quries
node = XmlNode.from_query('node@attr1="value1"@attr2="value2"')
nodes = XmlNode.from_queries(
{
"node@attr1='value1'@attr2='value2'": {
"child1@attr1='value1'": None,
"child2@attr2='value2'": None,
}
}
)
Searching a specific node
Return the first XmlNode with the given query. Query can be a name with attributes.
parent = node.find("node")
child1 = node.find("child1@attr1")
child2 = node.find("child2")
Generate a xml file
Using the to_xml()
function that return the XmlNode as an XML string.
with open('sample.xml', 'w', encoding='utf-8') as f:
f.write(node.to_xml())
Contributing
Coming soon.
Testing
python -m unittest discover -s xml_generator/tests -p "test*.py"
Building
python .\setup.py sdist bdist_wheel
Deployment
twine upload dist/*
License
License :: OSI Approved :: MIT License
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
Built Distribution
Close
Hashes for xml-generator-seobaeksol-0.2.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 638c82efc673194ca2fdce18dcee72b64f68be6bf1b9a208491a9ae4035525bd |
|
MD5 | f6d57ce7f459f92ca80c3397ad584481 |
|
BLAKE2b-256 | f448f363e4a6edce585ed97f85dbbd7acbcb6b1c9a0fcebe3608e1f908884ac8 |
Close
Hashes for xml_generator_seobaeksol-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e5cc6f72c94e603fd0bdb785436ca8e4447a273d0c93c7e05a76f45ca89a61c4 |
|
MD5 | 6b4666cc3ea9d5ef48a8a2ac25e3fc38 |
|
BLAKE2b-256 | ca4283977be6bce5f0736f4f55442c6a67e227a75b07c84f6e59a09a9cb8784b |