oxml
🌐 EN , Change language

Documentation

XPath 1.0 Evaluation Engine

Query and traverse XML trees with complete compliance, type conversion, and sub-expression optimization.

Syntax & Axes

oxml implements the complete W3C XPath 1.0 specification, including all 13 navigational axes:

  • child:: and descendant::
  • parent:: and ancestor::
  • following-sibling:: and preceding-sibling::
  • attribute:: (or @attr)
  • self:: and descendant-or-self:: (or //)

Standard Functions

Built-in support for all core XPath 1.0 function libraries:

  • Node-set functions: count(), id(), local-name(), namespace-uri(), name()
  • String functions: string(), concat(), starts-with(), contains(), substring-before(), substring-after(), substring(), string-length(), normalize-space(), translate()
  • Boolean functions: boolean(), not(), true(), false(), lang()
  • Number functions: number(), sum(), floor(), ceiling(), round()

Rust API

Evaluate queries easily from Rust code:

use oxml::{Document, Value};

let xml = r#"<store><book price="20"/><book price="40"/></store>"#;
let doc = Document::parse(xml)?;

// Select nodes
let books = doc.select("//book[@price > 25]")?;
assert_eq!(books.len(), 1);

// Evaluate numerical expressions
let total: f64 = doc.eval_number("sum(//book/@price)")?;
assert_eq!(total, 60.0);