elementpath
XPath 1.0/2.0/3.0/3.1 parsers and selectors for ElementTree and lxml
Decision gist · record as of 2026-08-14
Yes. The package is actively maintained, has no dependencies, supports current Python versions, carries no known vulnerabilities, and solves a real gap—providing XPath 2.0+ support for ElementTree and lxml. Install it if you need to query XML with XPath expressions beyond version 1.0.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.10 or later.
- Low install friction with no runtime dependencies.
- Active maintenance with a release 6 days ago and recent commits.
License · maintenance · safety
MIT (permissive) — MIT license is permissive, allowing use in commercial and proprietary projects with minimal restrictions.
last release 2026-08-08 (6 days) · last repo commit 2026-08-08 · 91 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 8,932,722 downloads/mo, #1,576 on PyPI
Alternatives
Verify before relying
pip install elementpath
import elementpath
from xml.etree import ElementTree
root = ElementTree.XML('<A><B1/><B2><C/><D/></B2></A>')
results = elementpath.select(root, '/A/B2/*')- Performance characteristics when querying large XML documents or complex XPath expressions.
- Completeness of XPath 3.0/3.1 feature coverage relative to the official specifications.
What it is and what it does
elementpath is an XPath parser and selector library that extends ElementTree and lxml with support for XPath 2.0, 3.0, and 3.1 expressions. While lxml already provides XPath 1.0 natively, elementpath fills the gap for higher XPath versions on both standard ElementTree and lxml data structures. The package implements a Pratt-style top-down operator precedence parser and exposes a simple API: the `select()` function returns results in standard XPath format (a list or elementary datatype), while `iter_select()` provides a generator for iteration. For repeated queries, you can instantiate a `Selector` object with a compiled XPath expression and apply it to multiple XML trees.
The library defaults to XPath 2.0 but allows you to specify alternative parsers via the `parser` argument. XPath 3.0 and 3.1 are available through subpackages to keep the default import focused. It has no runtime dependencies, installs cleanly, and is actively maintained with support for Python 3.10 through 3.15.
Use it for
- Query XML documents using XPath 2.0+ expressions when ElementTree's built-in XPath 1.0 support is insufficient.
- Migrate XPath queries from other tools to Python by using standard XPath 2.0/3.0 syntax on ElementTree data.
- Apply the same compiled XPath selector to multiple XML documents efficiently using the Selector class.
- Use advanced XPath 3.0 features like math functions when processing scientific or technical XML data.
- Extract nested XML elements and attributes with complex path expressions without manual tree traversal.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
The package is actively maintained, has no dependencies, supports current Python versions, carries no known vulnerabilities, and solves a real gap—providing XPath 2.0+ support for ElementTree and lxml. Install it if you need to query XML with XPath expressions beyond version 1.0.
Install
elementpath on PyPI
Before you install
Low install friction with no runtime dependencies. Active maintenance with a release 6 days ago and recent commits. Supports Python 3.10 through 3.15.
Requires Python 3.10 or later.
License in practice
MIT license is permissive, allowing use in commercial and proprietary projects with minimal restrictions.
Quickstart
pip install elementpath
import elementpath
from xml.etree import ElementTree
root = ElementTree.XML('<A><B1/><B2><C/><D/></B2></A>')
results = elementpath.select(root, '/A/B2/*')
Verify before relying
- Performance characteristics when querying large XML documents or complex XPath expressions.
- Completeness of XPath 3.0/3.1 feature coverage relative to the official specifications.
Package facts
| License | MIT permissive |
| Python support | Supports the current Python release >=3.10 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | None |
| Maintenance | Actively maintained 6 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 8,932,722 / month, #1,576 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableIntended Audience :: DevelopersIntended Audience :: Information TechnologyIntended Audience :: Science/ResearchOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.15Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: Software Development :: LibrariesTopic :: Text Processing :: Markup :: XML |
Evidence: elementpath-5.1.4-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “xpath selector for elementtree”
- elementpathProvides XPath 1.0, 2.0, 3.0, and 3.1 selectors for querying…
- cssselect2cssselect2 parses and matches CSS4 selectors against markup documents…
- cssselectcssselect parses CSS3 selectors and translates them to XPath 1.0…
Give your agent the search over MCP, or paste the wish link into any chat.
More Libraries packages
urllib3 is an HTTP client library that provides thread-safe connection pooling, SSL/TLS verification, multipart file uploads, request retries, compression support, and proxy handling for Python applications.
Requests is a Python HTTP library that simplifies sending HTTP/1.1 requests with automatic handling of headers, authentication, cookies, and response parsing.
Pluggy provides a plugin system that lets you define hook specifications and register implementations to be called in sequence, enabling extensible Python applications without tight coupling.
Install it if you're building an extensible application or framework.
Provides parsing, arithmetic, and recurrence rule computation for dates and times, with timezone support and iCalendar RFC compliance.
Install it if you need to parse flexible date strings, compute relative dates, handle timezones, or work with recurrence rules—it's the de facto choice for these tasks.
Six provides utility functions to write Python code that runs on both Python 2.7 and Python 3.3+, smoothing over language differences between the two versions.
pytest is a testing framework that lets you write test functions using plain assert statements and automatically discovers and runs them, with detailed failure reporting.
See also cssselect · lxml · saxonche · parsel · itemloaders · cssselect2 · xmlunittest · objectpath · jsonpath · meld3