A simple xml to json converter
Project description
This Python script provides a simple way to work with XML files.
Key Features:
Element Class: Represents an XML element and provides a toDict method to convert it into a Python dictionary.
XmlDocument Class: Represents an entire XML document. It allows you to:
- Load XML from a file or a string.
- Dump the XML document as a string.
- Get the XML document as bytes.
- Iterate through all elements in the document.
- Convert the XML document to a Python dictionary.
- Convert the XML document to a JSON string with optional indentation.
Example Usage:
from simple_xml_to_json import XmlDocument
# Load an XML file named example.xml
doc = XmlDocument(filename='example.xml')
# Convert the XML to a JSON string with indenting for readability
json_str = doc.toJson(indent=4)
# Save the JSON string to a file named example.json
with open('example.json', 'w') as f:
f.write(json_str)
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
File details
Details for the file simple_xml_to_json-0.0.2.tar.gz.
File metadata
- Download URL: simple_xml_to_json-0.0.2.tar.gz
- Upload date:
- Size: 3.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5267a21652b0a324ca5409628bbaf8d7eeb26b4ebc88f1d05318706b1f7e892b
|
|
| MD5 |
10fe43c15605994105906dbe72162e04
|
|
| BLAKE2b-256 |
9dc447fa459104c5662fb0f04378039f0c4fb634c0cb5fad3215b06602102104
|