Light-weight, simple and fast XML parser with XPath support
Project description
Python bindings for pugixml
pugixml is a light-weight C++ XML processing library. It features:
- DOM-like interface with rich traversal/modification capabilities
- Extremely fast non-validating XML parser which constructs the DOM tree from an XML file/buffer
- XPath 1.0 implementation for complex data-driven tree queries
- Full Unicode support with Unicode interface variants and automatic encoding conversions
Documentation
- pugixml-python
- pugixml
Example
Loading XML document from file:
from pugixml import pugi
doc = pugi.XMLDocument()
result = doc.load_file('xgconsole.xml')
if not result:
print('parse error: status=%r description=%r' % (result.status, result.description()))
Searching for nodes/attributes with predicates:
tools = doc.child('Profile').child('Tools')
# Find child via predicate (looks for direct children only)
node = tools.find_child(lambda x: x.attribute('AllowRemote').as_bool())
print(node.attribute('Filename').value())
# Find node via predicate (looks for all descendants in depth-first order)
node = doc.find_node(lambda x: x.attribute('AllowRemote').as_bool())
print(node.attribute('Filename').value())
# Find attribute via predicate
attr = tools.last_child().find_attribute(lambda x: x.name() == 'AllowRemote')
print(attr.value())
Selecting nodes via XPath expression:
tools = doc.select_nodes('/Profile/Tools/Tool[@AllowRemote="true" and @DeriveCaptionFrom="lastparam"]')
for tool in tools:
print(tool.node().attribute('Filename').value())
Using query objects and variables:
varset = pugi.XPathVariableSet()
var = varset.add('remote', pugi.XPATH_TYPE_BOOLEAN)
query_remote_tools = pugi.XPathQuery('/Profile/Tools/Tool[@AllowRemote = string($remote)]', varset)
var.set(True)
tools_remote = query_remote_tools.evaluate_node_set(doc)
for tool in tools_remote:
tool.node().print(pugi.PrintWriter())
var.set(False)
tools_local = query_remote_tools.evaluate_node_set(doc)
for tool in tools_local:
tool.node().print(pugi.PrintWriter())
Installation
Installing a package from PyPI
pip install pugixml
Building a package from source
-
Requirements:
- C++17 compatible compiler (see supported compilers)
- CMake ≥ 3.12
-
Installing a package from PyPI:
pip install --no-binary=:all: pugixml
-
Installing the development version from the git repository:
pip install git+https://github.com/miute/pugixml-python.git
License
- pugixml-python is licensed under the MIT License.
- pugixml is licensed under the MIT License.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file pugixml-0.6.0.tar.gz
.
File metadata
- Download URL: pugixml-0.6.0.tar.gz
- Upload date:
- Size: 350.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | df3b6442e5a8cefb3ee08a75f4cdab5490ca01d0a5a85e8be9f1fb9ffd6b060b |
|
MD5 | c87a3053658534ff448f2ca621c0b729 |
|
BLAKE2b-256 | c9158b7c0aa298ee1e8e66fc1bf38ae898365e86614768c1547bdc24f01daa69 |
File details
Details for the file pugixml-0.6.0-cp312-cp312-win_amd64.whl
.
File metadata
- Download URL: pugixml-0.6.0-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 263.0 kB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 42a2fe89d4afff027bb0fa6647be87a8afc8c93665cbad8fd82f8bc97fd093d8 |
|
MD5 | 1518737ff10aa08eec176d6e44814d41 |
|
BLAKE2b-256 | 199cc74de2d0ae580f9179a97c440a1f8a02e25d3b11572309c9b2a9439fa7c4 |
File details
Details for the file pugixml-0.6.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: pugixml-0.6.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 376.2 kB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4ffe1de4d0dc6706989eaad46062f639fa52d620301e7158aea365650756f97d |
|
MD5 | c5f6dda386106ff1a7e79a44bc2f833b |
|
BLAKE2b-256 | 9fc100e34f02d6902ca8fad68a5454f4d2342343ce0b5477c5ab64ddfe63a179 |
File details
Details for the file pugixml-0.6.0-cp312-cp312-macosx_12_0_x86_64.whl
.
File metadata
- Download URL: pugixml-0.6.0-cp312-cp312-macosx_12_0_x86_64.whl
- Upload date:
- Size: 270.0 kB
- Tags: CPython 3.12, macOS 12.0+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 01bd7bd553e6063ac982e7427542a3d5bfd11839462b432b33b4bf77388039c8 |
|
MD5 | 8d95dc5d5fd11c95990175407c19b1f0 |
|
BLAKE2b-256 | d08bc678291b34c8f5ee36b364d02c1d19b1710e371826f896b5f24fb2baedaf |
File details
Details for the file pugixml-0.6.0-cp312-cp312-macosx_12_0_arm64.whl
.
File metadata
- Download URL: pugixml-0.6.0-cp312-cp312-macosx_12_0_arm64.whl
- Upload date:
- Size: 242.3 kB
- Tags: CPython 3.12, macOS 12.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 467a967f171fae98c3daa5716042d73ed3f00526934758e32efe1f5f18cf25bf |
|
MD5 | a109656240f861dd35e829d572e3adbf |
|
BLAKE2b-256 | 36d8206796e7ca8b3c19f4ce9e22b9278547e1dcab81af3aa3bc6a3a5bc3840e |
File details
Details for the file pugixml-0.6.0-cp311-cp311-win_amd64.whl
.
File metadata
- Download URL: pugixml-0.6.0-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 260.7 kB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2735fc2411940d23bb77025662e1a2a56f935a2f9f8bfea1cd7587d9c0bad8ea |
|
MD5 | b879e36e46e48597e3dd27b98a6da5ec |
|
BLAKE2b-256 | eaa2d26c2be8ab0ce1fe3e2897557102dd07fc439d41163296fd974c6c7845c1 |
File details
Details for the file pugixml-0.6.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: pugixml-0.6.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 376.1 kB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5652728fcb995c1ff484be6c210a33c4fe919e8d289b33945e3943b416114c9d |
|
MD5 | 36e575f2dd4522098bfb9f2dedab8553 |
|
BLAKE2b-256 | 00daab17acf70e15948685fa909a488676bb232050e434b22a873fc05b2c3a7d |
File details
Details for the file pugixml-0.6.0-cp311-cp311-macosx_12_0_x86_64.whl
.
File metadata
- Download URL: pugixml-0.6.0-cp311-cp311-macosx_12_0_x86_64.whl
- Upload date:
- Size: 262.3 kB
- Tags: CPython 3.11, macOS 12.0+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a400dbd465ba12d7b4a774f87048bcd7cf564f8eec0bb2defb247098ce580dea |
|
MD5 | 84775ad4eed81024b4fb348fe7be2eb4 |
|
BLAKE2b-256 | 7eb4676fd33516d0deaefb3fe2aff9ed88d63410240c0064145004e5758c815d |
File details
Details for the file pugixml-0.6.0-cp311-cp311-macosx_12_0_arm64.whl
.
File metadata
- Download URL: pugixml-0.6.0-cp311-cp311-macosx_12_0_arm64.whl
- Upload date:
- Size: 240.4 kB
- Tags: CPython 3.11, macOS 12.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9aa4f3d7f4da5395f1500bfb6a3da91fc69cc2286af129dd36dcd299ff965848 |
|
MD5 | 11cdfe3d8d74edc3d7a137411b3bb7a5 |
|
BLAKE2b-256 | 1ec162020d5e0440cb934081ae8136014415307c30dc4dfb60e469198328aa6f |
File details
Details for the file pugixml-0.6.0-cp310-cp310-win_amd64.whl
.
File metadata
- Download URL: pugixml-0.6.0-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 260.2 kB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1cd76be3ef653ea3c48863c486339b15c5e0d15e25d65d2cbd02d8a007768937 |
|
MD5 | 87b1be0de28f4cdbcfadab237af88760 |
|
BLAKE2b-256 | 7b9c8014d838a273cd0db575cd9da8fa3960719980b0f6dec5ccb0f460aa2967 |
File details
Details for the file pugixml-0.6.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: pugixml-0.6.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 374.9 kB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 675d949d2428738b0d040591756bdbafd93c8b69d0a4a99be5553e3e52ff9315 |
|
MD5 | dcc2a54dde1fe86b0555d54bf2fac884 |
|
BLAKE2b-256 | 9b9a2d0357010eed290fc2e191dd869bb99b4f47d8570afd1332033cd30887a7 |
File details
Details for the file pugixml-0.6.0-cp310-cp310-macosx_12_0_x86_64.whl
.
File metadata
- Download URL: pugixml-0.6.0-cp310-cp310-macosx_12_0_x86_64.whl
- Upload date:
- Size: 260.9 kB
- Tags: CPython 3.10, macOS 12.0+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f843e3638094aecd5160016f63285d51908a0c4c52bcfed9489f0e397d1349ed |
|
MD5 | 0994eafe23bc5abd0e1040636347bec2 |
|
BLAKE2b-256 | 465032517e9c840bfaedc64028578f7a4a497ffb5cfec69390578828eb8ba103 |
File details
Details for the file pugixml-0.6.0-cp310-cp310-macosx_12_0_arm64.whl
.
File metadata
- Download URL: pugixml-0.6.0-cp310-cp310-macosx_12_0_arm64.whl
- Upload date:
- Size: 239.0 kB
- Tags: CPython 3.10, macOS 12.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9cf1e1d8943b5c09bb52477d03590da0dbbc835d93a42bb9e3f035a4ad61c33c |
|
MD5 | ccdba05ea04b7bf8f3f80e5d3057ae1b |
|
BLAKE2b-256 | 3427c696f24b9b0b31ff6c1d56bbcc414c489d68237623b9645e2291c27d7229 |
File details
Details for the file pugixml-0.6.0-cp39-cp39-win_amd64.whl
.
File metadata
- Download URL: pugixml-0.6.0-cp39-cp39-win_amd64.whl
- Upload date:
- Size: 242.0 kB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e6002b7995a3bf54328142c4626ef5fe83e9e0af7eae5d94e19be3d6605e73c1 |
|
MD5 | 657a22fe6b13faa53f754fa6283ea85f |
|
BLAKE2b-256 | 5ea5926fe927025927e4733386d5195bb25a70710fcd4ec005105d1fb3c26fdb |
File details
Details for the file pugixml-0.6.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: pugixml-0.6.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 375.2 kB
- Tags: CPython 3.9, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2f79e885bb28d834c7870fbac47d61e3d175e37b90119706c718ba1175bb379e |
|
MD5 | 3bc4f1a1752444282b4d468aed7d88ca |
|
BLAKE2b-256 | c63e8577ac4fc4c0042702413749713f0db78a49f3eb8257db7857e1fb7b8a8d |
File details
Details for the file pugixml-0.6.0-cp39-cp39-macosx_12_0_x86_64.whl
.
File metadata
- Download URL: pugixml-0.6.0-cp39-cp39-macosx_12_0_x86_64.whl
- Upload date:
- Size: 261.0 kB
- Tags: CPython 3.9, macOS 12.0+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a883e6555be0983a76869ef3ec4aa99457cbf9f63be7accd404c66269a40ef33 |
|
MD5 | 5c4f18c0af640ceaf2d174f7a753a975 |
|
BLAKE2b-256 | 28e832b1a46bd7a85998863acaf60a3848cf6f37670e08f50f52b7079ae4948f |
File details
Details for the file pugixml-0.6.0-cp39-cp39-macosx_12_0_arm64.whl
.
File metadata
- Download URL: pugixml-0.6.0-cp39-cp39-macosx_12_0_arm64.whl
- Upload date:
- Size: 239.1 kB
- Tags: CPython 3.9, macOS 12.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 032c07543a74a40c469a6c4d3e33462c36bfecc407d10e23dfdae25188ce4947 |
|
MD5 | 14ee896aa685689b2f8af63c935976de |
|
BLAKE2b-256 | 14ce73a9a0bcc385eb4ba224e9f9ef0aab69186aadecc2ca8fe97e46486e3811 |
File details
Details for the file pugixml-0.6.0-cp38-cp38-win_amd64.whl
.
File metadata
- Download URL: pugixml-0.6.0-cp38-cp38-win_amd64.whl
- Upload date:
- Size: 259.9 kB
- Tags: CPython 3.8, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2b538df537a3879243479b801879dcc8bfff8d637d16f183dd10736f85364f4b |
|
MD5 | a567e3dc68ca4d6e7c527657a4163b78 |
|
BLAKE2b-256 | 13a8e02d999698c2380b14e9c2b4f2eb9e16c00c16a6568e09c0c9db0e0b4614 |
File details
Details for the file pugixml-0.6.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: pugixml-0.6.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 374.6 kB
- Tags: CPython 3.8, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 18e0a832eee6b8de1ec299aac2ffa3d9cb526b69242ca1e815f28bf09b5dcca7 |
|
MD5 | a46ec7c676b77689fe494a6051fd1437 |
|
BLAKE2b-256 | 216f283c9e04cf722c333b98765fc9cbc19a71538a6ff41a4f4426922f63d91e |
File details
Details for the file pugixml-0.6.0-cp38-cp38-macosx_12_0_x86_64.whl
.
File metadata
- Download URL: pugixml-0.6.0-cp38-cp38-macosx_12_0_x86_64.whl
- Upload date:
- Size: 260.5 kB
- Tags: CPython 3.8, macOS 12.0+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 404f38d7826774a2a4adf6462e22ff36cdfdbb45f61813ba4265c0e5a65eb300 |
|
MD5 | bddf3d3e3d85208f5e33f40614b2a3b5 |
|
BLAKE2b-256 | 7d3182f453965f31a6d291c247d3767f6262667aad560d1419d8deb029b01b48 |
File details
Details for the file pugixml-0.6.0-cp38-cp38-macosx_12_0_arm64.whl
.
File metadata
- Download URL: pugixml-0.6.0-cp38-cp38-macosx_12_0_arm64.whl
- Upload date:
- Size: 260.5 kB
- Tags: CPython 3.8, macOS 12.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4cce10aeca846efb9d3b05071708667b244b6e87a63ce38d957fd90c881a9546 |
|
MD5 | 683e744dbcf256f110220c9fd5d5d292 |
|
BLAKE2b-256 | 32f53abb07bc922d42c93f01f31cdaad89b668e37500d72fa26ffb50fd03ded2 |