XML Generation Package to Generating Big xmls faster without any memory leakage issue
Project description
What is bxml ?
A Python library designed for efficiently generating large XML files. BXML leverages a native C extension to store and process data, enabling it to manage substantial datasets and generate XMLs with improved performance.
Some key benefits of using the BXML library:
-
Enhanced Performance with C Language: Utilizes C programming to optimize the addition of new XML elements, attributes, and the overall process of generating and saving XML files.
-
Efficient Memory Management: Allocates memory using C, ensuring automatic release when there are no references to the XML data, reducing memory consumption.
-
Handling Large Datasets: Leverages C language to efficiently process and manage XML files with substantial data, ensuring better performance and scalability.
Usage
1. Import Library in python
from bxml import *
2. Initialize the root XML element.
root = etree.Element("Root")
# Sample XML File
# <Root>
# </Root>
3. Add a child element to the root element and assign a value to the XML tag.
root = etree.Element("Root")
child1 = etree.SubElement(root, "Child1")
child1.text = 12.33
child2 = etree.SubElement(root,"Child2")
child2.text = 'bxml'
# Sample XML File
# <Root>
# <Child1>12.33</Child1>
# <Child2>bxml</Child2>
# </Root>
4. Add an attribute to the XML element.
root = etree.Element("Root")
child1 = etree.SubElement(root, "Child1")
child1.text = 12.33
child2 = etree.SubElement(root,"Child2")
child2.text = 'bxml'
child2.set("name","Krishna")
# Sample XML File
# <Root>
# <Child1>12.33</Child1>
# <Child2 name='Krishna'>bxml</Child2>
# </Root>
5. Search for an XML element using its tag.
root = etree.Element("Root")
child1 = etree.SubElement(root, "Child1")
child1.text = 12.33
child2 = etree.SubElement(root,"Child2")
child2.text = 'bxml'
child2.set("name","Krishna")
search = root.findAll('Child1')
search[0].text = 50
# Sample XML File
# <Root>
# <Child1>50</Child1>
# <Child2 name='Krishna'>bxml</Child2>
# </Root>
6. Remove an element from the XML.
root = etree.Element("Root")
child1 = etree.SubElement(root, "Child1")
child1.text = 12.33
child2 = etree.SubElement(root,"Child2")
child2.text = 'bxml'
child2.set("name","Krishna")
search = root.findAll('Child1')
search[0].text = 50
etree.remove(child1)
# Sample XML File
# <Root>
# <Child2 name='Krishna'>bxml</Child2>
# </Root>
7. Generate XML File.
root.save("Test",True)
# The save function accepts three parameters, as described below:
# root.save(file_name,xmlDeclaration = True, encoding = 'ASCII')
#
#
# file_name: The name of the file to save the XML data.
# xmlDeclaration (optional): A boolean value to specify whether to include the XML declaration. Default is True.
# encoding (optional): The character encoding to use for the file. Default is 'ASCII'.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bigger_xml-0.0.2.tar.gz.
File metadata
- Download URL: bigger_xml-0.0.2.tar.gz
- Upload date:
- Size: 7.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9563aa4ce4425e21acafd96667b23bcdae947132e6e6a3bf7ca848019331d324
|
|
| MD5 |
89741f3e19492b2e4bf3978b2186af60
|
|
| BLAKE2b-256 |
fa49aa0bb627b42ccfa2276eb1e30d76567eb1f8e31f610f65ed8d9c4e1be338
|
File details
Details for the file bigger_xml-0.0.2-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: bigger_xml-0.0.2-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 12.8 kB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d960bfe758ead5594431d60fb6c08cc91c5faa16fa9e884be68994de76c068f2
|
|
| MD5 |
17b1ba21693e960502b812fcf21b353e
|
|
| BLAKE2b-256 |
f978a27f210a0b3ed995f8ce8994c1ab33d6b4db3ad142438ccef97805c7abfc
|