An open API service indexing awesome lists of open source software.

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

Awesome Lists containing this project

README

          

Like my work? consider supporting it!

[![BuyMeACoffee](https://img.shields.io/badge/Buy%20Me%20a%20Coffee-ffdd00?style=for-the-badge&logo=buy-me-a-coffee&logoColor=black)](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.



Package version


Supported Python versions

## 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
```