Skip to main content

Crate leptris

Crate leptris 

Source
Expand description

Idiomatic Rust bindings for libleptris, a pure-C99 XML 1.0 parser with an XPath 1.0 engine and SAX front end.

use leptris::Document;

let doc = Document::parse(b"<root><a id='1'>hello</a></root>").unwrap();
let root = doc.root().unwrap();
assert_eq!(root.name(), "root");

let hits = doc.xpath("//a").unwrap();
assert_eq!(hits.len(), 1);
assert_eq!(hits.element(0).unwrap().text(), Some("hello"));

The C library is resolved at link time: set LEPTRIS_LIB_PATH (see build.rs) or install libleptris on the library path.

Modules§

sax
Event-driven parsing with closures — a Rust-flavored veneer over leptris_sax_parse.

Structs§

Attributes
Iterator over an element’s attributes.
Document
A parsed XML document. Owns the C document; freed on drop.
Element
An element, borrowed from its document for its whole lifetime.
ElementChildren
Iterator over child elements.
XPathResult
A live XPath result, borrowed from its document; freed on drop.

Enums§

Error
Error surfaced by every fallible binding call. Mirrors the LeptrisStatus codes from the C API.
XPathNodeKind
The XPath node kind reported by XPathResult::kind.

Type Aliases§

Result