xml-analyser
A tool showing various statistics about element usage in an arbitrary XML file.
Usage:
xml-analyser example.xml
If example.xml looks like this:
<example>
<foo>
<bar a="1" b="2">
<baz>This has text</baz>
</bar>
</foo>
<foo>
<bar a="1" b="2" c="3">
<baz>More text here</baz>
</bar>
<baz d="1" />
</foo>
</example>
xml-analyzer example.xml outputs this:
{
"example": {
"count": 1,
"parent_counts": {},
"attr_counts": {},
"child_counts": {
"foo": 2
}
},
"foo": {
"count": 2,
"parent_counts": {
"example": 2
},
"attr_counts": {},
"child_counts": {
"bar": 2,
"baz": 1
}
},
"bar": {
"count": 2,
"parent_counts": {
"foo": 2
},
"attr_counts": {
"a": 2,
"b": 2,
"c": 1
},
"child_counts": {
"baz": 2
}
},
"baz": {
"count": 3,
"parent_counts": {
"bar": 2,
"foo": 1
},
"attr_counts": {
"d": 1
},
"child_counts": {},
"count_with_text": 2,
"max_text_length": 14
}
}
Truncating the XML instead
The --truncate option works differently: the XML file passed to this tool will be truncated, by finding any elements with more than two child elements of the same type and truncating to just those two elements.
This can reduce a large XML file to something that's easier to understand.
Given an example document like this one:
<example>
<atop title="Example 1" />
<atop title="Example 2" />
<atop title="Example 3" />
<atop title="Example 4" />
<foo>
<bar a="1" b="2">
<baz>This has text</baz>
</bar>
<bar a="2" b="2">
<baz>This has text</baz>
</bar>
<bar a="3" b="2">
<baz>This has text</baz>
</bar>
<bar a="4" b="2">
<baz>This has text</baz>
</bar>
</foo>
<foo>
<bar a="1" b="2" c="3">
<baz>More text here</baz>
</bar>
<baz d="1" />
</foo>
<foo>
<bar a="1" b="2" c="3">
<baz>More text here</baz>
</bar>
<baz d="1" />
</foo>
</example>
The following command:
xml-analyser example.xml --truncate
Will return the following:
<example>
<atop title="Example 1" />
<atop title="Example 2" />
<foo>
<bar a="1" b="2">
<baz>This has text</baz>
</bar>
<bar a="2" b="2">
<baz>This has text</baz>
</bar>
</foo>
<foo>
<bar a="1" b="2" c="3">
<baz>More text here</baz>
</bar>
<baz d="1" />
</foo>
</example>
Metadata
Release files for xml-analyser 1.3
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 | Actions |
|---|---|---|---|---|
| xml-analyser-1.3.tar.gz | 7.6 kB | Without provenance | Details for xml-analyser-1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| xml_analyser-1.3-py3-none-any.whl | Python 3 | none | any | Details for xml_analyser-1.3-py3-none-any.whl |
Total release size: 15.8 kB
Release files / xml-analyser-1.3.tar.gz
| Download URL | xml-analyser-1.3.tar.gz |
|---|---|
| Size | 7.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
16e9ee96a3e46897c8d708bb84a8d41c56cf31bbdfb457963231ef9cc1e4c762
|
|
BLAKE2b-256 checksum How to use checksums |
9097e8e486ca3cb4b616b78bde270917a13bfec468b0596603a270bef0180567
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10
|
Release files / xml_analyser-1.3-py3-none-any.whl
| Download URL | xml_analyser-1.3-py3-none-any.whl |
|---|---|
| Size | 8.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ed111169b963f0a47aa7114d6eed113dac5ad2528d2005a4ba7bf4f1899310a8
|
|
BLAKE2b-256 checksum How to use checksums |
ba1ca94d746c0325d613d05beb70c1b59b6bad1795cedbaa0350eddab2b8d975
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10
|
Security for xml-analyser 1.3
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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.