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
pugixml-0.3.0.tar.gz
(326.8 kB
view hashes)
Built Distributions
pugixml-0.3.0-cp39-cp39-win_amd64.whl
(249.3 kB
view hashes)
pugixml-0.3.0-cp38-cp38-win_amd64.whl
(249.3 kB
view hashes)
Close
Hashes for pugixml-0.3.0-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fb4289864a5e6d6062696e9cf5fba9457f9559d907dd07c5c83b663cfe47366f |
|
MD5 | d022f5b014635f867f7ccf918240a119 |
|
BLAKE2b-256 | c308c89a2c1cea034b06c88d97ddbaaace385422e964832dc76d8f9ecfc1a385 |
Close
Hashes for pugixml-0.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4fe649a640ec644707198fedaaa6b47e565ef5205771e3cac8e1de2f20352268 |
|
MD5 | 5217c2f13c20bbaec1660aa59754e128 |
|
BLAKE2b-256 | d8c7a7dca1dfbe521a4665a5574981cc1ae64e30b6cbe94fcff1b80dd8f85272 |
Close
Hashes for pugixml-0.3.0-cp311-cp311-macosx_10_15_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 949592091e091ebc1ddff0028182d8f370b5bf8ed9eba5a21ea4bd3170f1363a |
|
MD5 | 8cf091f886b5adebcb1d92252bd27774 |
|
BLAKE2b-256 | a96ca4afebe61f77d9fe191e427c0dbd40a41af9841529f817a10f22a5d447ab |
Close
Hashes for pugixml-0.3.0-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b54811e41c0f8ab58a1ef9e4c8569dde6a4739d38c34711997bf94fc0604d756 |
|
MD5 | cc89b58a68fd031899ec8ec9fe1f2825 |
|
BLAKE2b-256 | ce11bb3095fb8068087d6d74a6732b7c0a2f2c64dd967003fe641f8ce1a586d0 |
Close
Hashes for pugixml-0.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d1cadf45e07e502926cb0132341d2a60756b4070a084f4cc712fd0b0cdbe468a |
|
MD5 | e4e4685160c563fba343372a59acf533 |
|
BLAKE2b-256 | 05a2c1393672ce1d3652522571ffc534f1965d56e697a162187faa8716f5eee5 |
Close
Hashes for pugixml-0.3.0-cp310-cp310-macosx_10_15_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0c7c94ccc08d421dd4b6286bbbd3a4036726402c02a9823ff9cbf19ffbd0d070 |
|
MD5 | 10f86543d9b6ebb0419f6615e679f23a |
|
BLAKE2b-256 | f9dcc27729f450d93850f4e6d6eea648b1d710133bd89b85baca5b4bdfa7a933 |
Close
Hashes for pugixml-0.3.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d2cca5938fa9e8737ea0fe16c5ac35648228f25a228cfa3371a8592aa905b35f |
|
MD5 | d94991cb8cee1e4808ef2a64029bc2e5 |
|
BLAKE2b-256 | ad3709bd20c441f777e72079aa07edd268697e1bf69fb7f2cfe87e17dd7ee9d2 |
Close
Hashes for pugixml-0.3.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9ce26ff5cd8aa8cfe68c1e7a05702b0134f2fc7821db17b97f708b863492600a |
|
MD5 | 96f8ff9b86c6c044fc2830f96d7c466f |
|
BLAKE2b-256 | 1036d60a5fbff2592411b02976c74d778e135cb924f39de737754db7def7e4a0 |
Close
Hashes for pugixml-0.3.0-cp39-cp39-macosx_10_15_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 62b66bb14fc89ef0c227db5f66c988f9c9139f270e8f014eb8e4508066a173d2 |
|
MD5 | fb603917e84ba322ab443debb7b6ed60 |
|
BLAKE2b-256 | a6b2b47b7368dc657307bdf21a7227b1e09104f91a37fe90bd2a88b3954d8f0e |
Close
Hashes for pugixml-0.3.0-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 47fce0a8b8757e67113367243ed06bf34a7eeacd56852725403b4255016851b6 |
|
MD5 | 3032f0f6dfcb98752111330f9f3e8c69 |
|
BLAKE2b-256 | 71f236065425312d47e13a9d03689a6d77ed3b166dd24688d7e934ffd8b9507e |
Close
Hashes for pugixml-0.3.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3d93d985a71737aecba7213012c6b52939796e857cf77254f90ca1a5b36b28ec |
|
MD5 | 32dce4988e7512dee7c9f42d290faa5c |
|
BLAKE2b-256 | e38ade47d93c1f9bac47771cb4f16f3fcf01464e5c03d805e668ceab908a515f |
Close
Hashes for pugixml-0.3.0-cp38-cp38-macosx_10_15_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7fe7dd4a4cd07444e74a71d305bd04bd806f28b69b0bfb89e9c4f0e0081f1044 |
|
MD5 | da6bdc4eb3bf726a2117d83e900b7ed1 |
|
BLAKE2b-256 | 347a1e4b236d219b0b7a99e82f67aa5bb9dd783f5d457f1d81bd1ed76d3f6118 |
Close
Hashes for pugixml-0.3.0-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 30fc71bcfb7981d73b9d0ca5417002501e3e023a9dd8c281d64c37a9a0cd6577 |
|
MD5 | 9ddef96cac1fd2632ab2584ee12b7796 |
|
BLAKE2b-256 | 88c794dc08b461df6ec5b491b2b157dce10b8168a49e094e7be100138bc7e9c8 |
Close
Hashes for pugixml-0.3.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 48157ff321b08b27047386f94fdce5ccc639487ea362ecdbd9316aa639b192e1 |
|
MD5 | 35fb04a4d7bed8988991cd594e1733eb |
|
BLAKE2b-256 | 356eec537fede32b11bc6596e9fcbede3b51af86b0e46e508018ff7074142ec3 |