A minimal reimplementation of `ET.tostring` that supports unescaped 'raw' text content.
Project description
AnyXml
A minimal reimplementation of ET.tostring that supports unescaped "raw" text content.
The standard library's ET.tostring always XML-escapes the text/tail content of elements (e.g. <, &), which makes it impossible to inject pre-built, already-valid XML fragments (or other raw strings) during serialization.
This class provides :meth:tostring, which behaves similarly to ET.tostring but additionally supports:
- Strings wrapped in :class:
RawTextare emitted verbatim during serialization, without any escaping; regularstrtext is still escaped according to XML rules. - Comment nodes (
ET.Comment) and processing instruction nodes (ET.ProcessingInstruction) are rendered as<!--...-->and<?...?>respectively. - Elements with no text and no children are rendered as self-closing tags (
<tag/>).
Example
>>> el = ET.Element("p")
>>> el.text = AnyXml.RawText("<b>bold</b>")
>>> AnyXml.tostring(el)
'<p><b>bold</b></p>'
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 anyxml-0.1.0.tar.gz.
File metadata
- Download URL: anyxml-0.1.0.tar.gz
- Upload date:
- Size: 1.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1d39aa376bb770f3f140086f7ab9756e12912b850700428780c3efc5f506fb00
|
|
| MD5 |
28e8cf834063b0454050184cc55658c5
|
|
| BLAKE2b-256 |
53cc5cea09e7969c9171445012d8507a428f38d7d7aaedb81c57aee3ee5a8a7a
|
Provenance
The following attestation bundles were made for anyxml-0.1.0.tar.gz:
Publisher:
publish.yml on BHznJNs/anyxml
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
anyxml-0.1.0.tar.gz -
Subject digest:
1d39aa376bb770f3f140086f7ab9756e12912b850700428780c3efc5f506fb00 - Sigstore transparency entry: 1808755931
- Sigstore integration time:
-
Permalink:
BHznJNs/anyxml@de63ea9b5daa1560047fcef1c3e0eb5ea33d2f53 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/BHznJNs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@de63ea9b5daa1560047fcef1c3e0eb5ea33d2f53 -
Trigger Event:
push
-
Statement type:
File details
Details for the file anyxml-0.1.0-py3-none-any.whl.
File metadata
- Download URL: anyxml-0.1.0-py3-none-any.whl
- Upload date:
- Size: 2.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8c5c99b26cb3d4de91b277fdfdc1a0181376bc387a978390429644c5087d502e
|
|
| MD5 |
519653ad77ee8ce16b61ff8bb4e58a2c
|
|
| BLAKE2b-256 |
3cc03c9df7fc59b6be46a400d7782c614213a53f4e2ff986c279ccc04e0eb57c
|
Provenance
The following attestation bundles were made for anyxml-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on BHznJNs/anyxml
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
anyxml-0.1.0-py3-none-any.whl -
Subject digest:
8c5c99b26cb3d4de91b277fdfdc1a0181376bc387a978390429644c5087d502e - Sigstore transparency entry: 1808755975
- Sigstore integration time:
-
Permalink:
BHznJNs/anyxml@de63ea9b5daa1560047fcef1c3e0eb5ea33d2f53 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/BHznJNs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@de63ea9b5daa1560047fcef1c3e0eb5ea33d2f53 -
Trigger Event:
push
-
Statement type: