This content is for v2.x version. Switch to the Stable version.
Roadmap
The v2.x line builds on the stable, round-trip-safe DOM from v1.x. Its headline goal is native XPath querying, plus supporting ergonomics for selecting and extracting data from a parsed tree.
Headline: XPath support Planned
Section titled “Headline: XPath support ”Today you navigate the tree with structural helpers such as
find_first_child,
get_elements_by_tag_name and find_first_by_attribute. v2 aims to add a
single expression-based entry point so you can locate nodes with familiar XPath
syntax instead of chaining calls.
The target API is a query_xpath method on
XmlDocument:
// Target API — not yet available.let titles = document.query_xpath("//book[@id='bk101']/title")?;for node_id in titles { let title = document.get_element(node_id)?; println!("{}", title.get_text_content());}Planned expression coverage
Section titled “Planned expression coverage”| Capability | Example | Status |
|---|---|---|
| Child & descendant steps | /catalog/book, //title | Planned |
| Attribute predicates | book[@id=‘bk101’] | Planned |
| Positional predicates | book[1], book[last()] | Planned |
| Wildcards | /catalog/*, @* | Planned |
| Namespace-qualified steps | //t:book via a bound prefix map | Exploring |
| Text & node tests | //title/text() | Exploring |
Design goals
Section titled “Design goals”- Zero-copy over the existing DOM — XPath evaluation returns
NodeIdvalues into the current tree, with no separate document model. - Namespace-aware — expressions resolve prefixes through the same
NamespaceDeclarationscope used elsewhere, keeping results round-trip-safe. - No
unsafe— consistent with the rest of the crate. - Incremental — child/descendant axes and attribute predicates ship first; richer axes and functions follow.
Beyond XPath
Section titled “Beyond XPath”| Area | Intent | Status |
|---|---|---|
| Streaming / SAX-style reader | Event callbacks for very large documents without building a full DOM. | Exploring |
| Pretty-printing option | Optional indentation on serialize alongside the existing compact output. | Exploring |
| Broader encoding support | Read non-UTF-8 declarations by transcoding to UTF-8 on parse. | Exploring |