python-elementpath
Port variant v14
Summary Xpath parsers and selectors (3.14)
Package version 5.1.4
Homepage https://github.com/sissaschool/elementpath
Keywords python
Maintainer Python Automaton
License Not yet specified
Other variants v15
Ravenports Buildsheet | History
Ravensource Port Directory | History
Last modified 27 NOV 2026, 01:15:48 UTC
Port created 27 NOV 2026, 01:15:48 UTC
Subpackage Descriptions
single *********** elementpath *********** .. elementpath-introduction The proposal of this package is to provide XPath 1.0, 2.0, 3.0 and 3.1 selectors for ElementTree XML data structures, both for the standard ElementTree library and for the `lxml.etree `_ library. For `lxml.etree `_ this package can be useful for providing XPath 2.0/3.0/3.1 selectors, because `lxml.etree `_ already has it's own implementation of XPath 1.0. Installation and usage ====================== You can install the package with *pip* in a Python 3.10+ environment:: pip install elementpath For using it import the package and apply the selectors on ElementTree nodes: .. code-block:: pycon >>> import elementpath >>> from xml.etree import ElementTree >>> root = ElementTree.XML('') >>> elementpath.select(root, '/A/B2/*') [, , ] The *select* API provides the standard XPath result format that is a list or an elementary datatype's value. If you want only to iterate over results you can use the generator function *iter_select* that accepts the same arguments of *select*. The selectors API works also using XML data trees based on the `lxml.etree `_ library: .. code-block:: pycon >>> import elementpath >>> import lxml.etree as etree >>> root = etree.XML('') >>> elementpath.select(root, '/A/B2/*') [, , ] When you need to apply the same XPath expression to several XML data you can also use the *Selector* class, creating an instance and then using it to apply the path on distinct XML data: .. code-block:: pycon >>> import elementpath >>> import lxml.etree as etree >>> selector = elementpath.Selector('/A/*/*') >>> root = etree.XML('') >>> selector.select(root) [, , ] >>> root = etree.XML('') >>> selector.select(root) [, , , ] Public API classes and functions are described into the `elementpath manual on the "Read the Docs" site `_. For default the XPath 2.0 is used. If you need XPath 1.0 parser provide the *parser* argument: .. code-block:: pycon >>> from elementpath import select, XPath1Parser >>> from xml.etree import ElementTree >>> root = ElementTree.XML('') >>> select(root, '/A/B2/*', parser=XPath1Parser) [, , ] For XPath 3.0/3.1 import the parser from *elementpath.xpath3* subpackage, that is not loaded for default: .. code-block:: pycon >>> from elementpath.xpath3 import XPath3Parser >>> select(root, 'math:atan(1.0e0)', parser=XPath3Parser) 0.7853981633974483 Note: *XPath3Parser* is an alias of *XPath31Parser*. If you need only XPath 3.0 you can also use a more specific subpackage, avoiding the loading of XPath 3.1 implementation: .. code-block:: pycon
Configuration Switches (platform-specific settings discarded)
PY314 ON Build using Python 3.14 PY315 OFF Build using Python 3.15
Package Dependencies by Type
Build (only) python314:dev:std
python-pip:single:v14
autoselect-python:single:std
Build and Runtime python314:primary:std
Download groups
main mirror://PYPIWHL/42/b0/b709cc33ccb0288f41f2d92dfd754d2ccf925cb9277a66effbc132cd004c
Distribution File Information
5ec8d7bb44b16c98414a6a95e20cb150f3cbfc3cac65edc14773288c7a937376 261881 python-src/elementpath-5.1.4-py3-none-any.whl
Ports that require python-elementpath:v14
python-xmlschema:v14 XML Schema validator and decoder (3.14)