xml-python
xml-python is a library for making Python objects from XML, designed to parse XML nodes using decorated functions. Last updated in January 2021 (v0.4.3), the project appears to be unmaintained with no public documentation beyond its minimal PyPI description.
Warnings
- gotcha The `xml-python` library has not been updated since January 2021, and there is no active public repository or detailed documentation available. This may indicate a lack of ongoing maintenance and potential compatibility issues with newer Python versions or security patches.
- gotcha When parsing XML from untrusted sources, all XML parsing libraries (including standard library modules like `xml.etree.ElementTree` and third-party ones) can be vulnerable to security risks like 'Billion Laughs' or 'XML External Entity (XXE)' attacks. Since `xml-python` lacks clear documentation on its parsing mechanisms and security hardening, it's crucial to exercise caution.
Install
-
pip install xml-python
Imports
- xml_objects
from xml_python import xml_objects
Quickstart
from xml_python import xml_objects
xml_data = """
<root>
<title>This is a title</title>
<text>This is some text</text>
</root>
"""
# Define a Python class to represent your XML structure
class MyNodeObject(xml_objects.XMLObject):
pass
# Use a decorator to associate the parser function with the 'root' tag
@xml_objects.node_parser(MyNodeObject, 'root')
def parse_root(parser, node):
# Extract data from child nodes
parser.title = node.find('title').text
parser.text = node.find('text').text
# Parse the XML string into the Python object
root_object = xml_objects.parse_string(xml_data)
print(f"Parsed Title: {root_object.title}")
print(f"Parsed Text: {root_object.text}")