https://github.com/nephi-dev/rxml
A Python library to read xml files written in rust
https://github.com/nephi-dev/rxml
cpython maturin pypy python rust xml
Last synced: about 1 month ago
JSON representation
A Python library to read xml files written in rust
- Host: GitHub
- URL: https://github.com/nephi-dev/rxml
- Owner: nephi-dev
- License: mit
- Created: 2023-04-26T14:15:46.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2025-10-08T14:20:13.000Z (4 months ago)
- Last Synced: 2025-10-08T16:16:40.996Z (4 months ago)
- Topics: cpython, maturin, pypy, python, rust, xml
- Language: Rust
- Homepage: https://pypi.org/project/rxml/
- Size: 105 KB
- Stars: 18
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Like my work? consider supporting it!
[](https://buymeacoffee.com/nephilim)
RXML
rxml is a simple python library to read xml files up to 2 times faster than python's xml(ElementTree) library.
## Installation
To install `rxml` you can use `pip`:
```bash
pip install rxml
```
Simply as that!
## Example usage
To a given xml with `test.xml` as name:
```xml
Example Name
Example Name
An Example Heading
An Example Body!
```
We write the following python code:
```python
from rxml import read_file
root_node = read_file("test.xml", "note")
```
where `"test.xml"` is the `file_name` and `"note"` is the `root_tag`.
After that we can simply iter through the children with:
```python
for node in root_node.children:
# do something with the node here
```
You can also write it to a file or string(refer to the `.pyi` file for the args).
```python
from rxml import Node, write_file
example_node = Node(
name="hello_world",
attrs={"example_attr": "example"},
text="Hello World!"
)
write_file(example_node, "test_ex.xml")
```
## Node attributes
This is how the `Node` looks like:
```python
class Node:
name: str
attrs: dict[str, str]
children: list[Node]
text: str
```