v0.0.13 pre-1.0 · MIT / Apache-2.0
Query and Edit XML in Safe Rust.
Parse, mutate, query with XPath 1.0, and validate with XSD natively, in the browser with WebAssembly, or from an AI agent via MCP. No unsafe code, no C dependencies.

One Engine, Four Runtimes, One Version Number
Run the same memory-safe XML engine natively in Rust, via terminal CLI, inside Claude and AI agents with MCP, or in the browser with WebAssembly.
// Pure Rust XML processing with full XPath 1.0
use oxml::{parse, XPath};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let doc = parse("<book id='b1'>Dune</book></library>")?;
let xpath = XPath::compile("//book[@id='b1']/text()")?;
assert_eq!(xpath.evaluate(&doc).to_str(&doc), "Dune");
println!("Parsed and queried with 100% safe Rust!");
Ok(())
} # Fast, robust command-line XML query, validation & formatting
oxml query "//book[@id='b1']/text()" library.xml
oxml format --indent 2 --empty-elements self-closing library.xml
oxml validate --schema schema.xsd library.xml
oxml inspect library.xml{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "xml_query",
"arguments": {
"xml": "<book id='b1'>Dune</book></library>",
"xpath": "//book[@id='b1']/text()"
}
}
} // Browser & Node.js ESM via WebAssembly
import init, { Document } from "@oxml/wasm";
await init();
const doc = Document.parse("<book id='b1'>Dune</book></library>");
const nodes = doc.select("//book[@id='b1']/text()");
console.log(nodes[0].textContent()); // "Dune" Why oxml
Every component is engineered for reliability, safety, and predictability across native Rust, CLI pipes, and browser environments.
Zero Unsafe Code
Enforced with #![forbid(unsafe_code)] at compile time. Zero raw pointer arithmetic, zero transmute tricks, zero undefined behaviour risks.
Generational Arena Tree
Cache-friendly contiguous arena with O(1) node recycling. Removed elements reuse slots with bumped generations, preventing stale handles.
XPath 1.0 Engine
Full specification evaluator supporting 13 axis steps, predicates, standard functions (count, contains, starts-with), and variable resolution.
Unified Ecosystem
CLI tool, WebAssembly bundle, JSON-RPC, LSP server, and MCP agent toolkit, all shipping under one version number with zero dependency drift.
How oxml Compares to Rust XML Peers
An honest look at capabilities across the Rust ecosystem, and when to pick something else.
| Capability / Guarantee | oxml | quick-xml | roxmltree | xot | xee |
|---|---|---|---|---|---|
| Memory Safety | #![forbid(unsafe_code)] | Safe Rust | Safe Rust | Safe Rust | Safe Rust |
| DOM Tree & Mutation | Mutable Arena DOM (O(1)) | Streaming (No DOM) | Read-Only (No DOM edit) | Mutable Arena DOM | Read-Only Tree |
| XPath Specification | W3C XPath 1.0 | None (Manual events) | None (Cursor traversal) | None (Tree traversal) | W3C XPath 3.1 |
| XML Schema (XSD) | Partial (see coverage) | None | None | None | None |
| Browser WebAssembly | Native (<220 KB, 0 C deps) | Supported (core reader) | Supported (read-only) | Supported (tree only) | Supported (engine) |
| AI Agent Tools (MCP) | Native (oxml-mcp) | None | None | None | None |
| Pick this crate when... | You need mutable DOM, XPath 1.0, and WASM under one safe, versioned crate | You need maximum streaming throughput on gigabyte files without a DOM | You need a lightweight, read-only cursor tree for static documents | You need fine-grained XML tree manipulation with full namespace support | You need XPath 3.1, XQuery, or XSLT 3.0 processing |
When Not to Use oxml — Honestly
Every architecture involves deliberate trade-offs. We recommend these alternatives when your requirements match their strengths:
Gigabyte Streaming (Without a DOM)
If you are processing multi-gigabyte log or financial transaction streams where building a document tree in memory is unnecessary, pick quick-xml. Its pull-based token parser avoids heap allocation overhead.
XPath 2.0+ / XQuery / XSLT
If you need XPath 2.0/3.1 functions, regular expressions, or XSLT stylesheets, pick xee (pure Rust) or Saxon. oxml focuses strictly on W3C XPath 1.0 compliance.
Full XSD 1.1 Complex Identity Constraints
If you require exhaustive W3C XML Schema 1.1 validation with complex schema redefinitions, pick libxml2 or Saxon until xmlschema achieves full 1.0 maturity.
What We Measure, and How
Validated against official W3C XML conformance suites and benchmarked against reproducible baselines.
- 0
- Unsafe blocks, enforced by #![forbid(unsafe_code)] at compile time
- 2.5x
- Throughput vs byte-by-byte scanning on SWAR delimiter benchmark
- 95.2%
- Pass rate on W3C XML Schema 1.0 core test suite subset
- O(1)
- Positional index predicates (e.g. [N] lookups) in generational arena