EasyXML presents a simplified view of an XML document.
Elements in the XML document, including the root-level document, are represented by EasyXML objects. Each EasyXML object has a _name attribute holding the name of the element represented by the EasyXML object, a dictionary called _attrs holding the element’s attributes, and a sequence called _content holding the content of the element. The _content sequence contains strings for the character data within the element (with whitespace stripped from the beginning and end), and other EasyXML objects for nested XML elements.
The content of the EasyXML object can be accessed directly as if it were a sequence itself. In addition, the element’s attributes themselves may be accessed by name on the EasyXML object.
For example, the XML fragment <zip code="12345">Schenectady, NY</zip> would be returned as an EasyXML object where name.``_name`` is 'zip', name.``_attrs`` is {'code': '12345'}, name. _content is ['Schenectady, NY'], name.``code`` is '12345', and name.``[0]`` is 'Schenectady, NY'.
Usage:
# Import the EasyXML class
from easy_xml import EasyXML
# Parse the file-like object `stream` into an EasyXML structure.
xmldoc = EasyXML.parseXML(stream)
# Find the first ``<hello>`` node in the document.
# If it exists, record its content in the `hello` variable.
# If not, record ``world`` in `hello`, and create a new
# ``<hello>world</hello>`` XML element at the top of the document.
for element in xmldoc:
if isinstance(element,EasyXML) and element._name == 'hello':
hello = ' '.join(element._content)
break
if hello is None:
hello = 'world'
element = EasyXML('hello', content=[hello])
xmldoc._content.insert(0, element)
# Convert the EasyXML structure back into a valid XML document.
xmlfile = str(xmldoc)
Notes:
Processing instructions and comments are ignored.
Only basic entity processing (<, >, and &) is performed.
Metadata
Release files for easy-xml 0.7.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| easy_xml-0.7.0.tar.gz | 9.2 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| easy_xml-0.7.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 15.9 kB
Release files / easy_xml-0.7.0.tar.gz
| Download URL | easy_xml-0.7.0.tar.gz |
|---|---|
| Size | 9.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6509524d92700555044a9ebb7533fa35d0b23f05fd092b5f5810a2afdbf0817a
|
|
BLAKE2b-256 checksum How to use checksums |
21018a7032bffdb539b3ec30b4857f7ef5758b9cf135cd7555c715ead3d51f5f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.7.2
|
Release files / easy_xml-0.7.0-py3-none-any.whl
| Download URL | easy_xml-0.7.0-py3-none-any.whl |
|---|---|
| Size | 6.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6ab4ef0a509198a18572b33ca5c2950e3e2d6858caca8b31417728881d8efa94
|
|
BLAKE2b-256 checksum How to use checksums |
92e91433d0a9880fd9c2d9af57fb87d7c2d7af1edf6794521ea1b54b325c507d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.7.2
|
Security for easy-xml 0.7.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.