RustyXML 0.1.0

A SAX-like streaming XML parser, and a DOM-like interface based on that

Homepage: https://github.com/Florob/RustyXML

Platform: Cargo

Language: Rust

License: MIT

View on registry: https://crates.io/crates/RustyXML/


RustyXML

RustyXML is a namespace aware XML parser written in Rust. Right now it provides a basic SAX-like API, and an ElementBuilder based on that.

The parser itself is derived from OFXMLParser as found in ObjFW https://webkeks.org/objfw/.

The current limitations are:

  • Incomplete error checking
  • Unstable API

This project tracks Rust's master branch.

Examples

Parse a string into an Element struct:

use xml::Element;
let elem: Option<Element> = "<a href='//example.com'/>".parse();

Get events from parsing string data:

use xml::{Event, Parser};
// Create a new Parser
let mut p = Parser::new();
// Feed data to be parsed
p.feed_str("<a href");
p.feed_str("='//example.com'/>");
// Get events for the fed data
for event in p {
 match event.unwrap() {
 Event::ElementStart(tag) => println!("<{}>", tag.name),
 Event::ElementEnd(tag) => println!("</{}>", tag.name),
 _ => ()
 }
}

This should print:

<a>
</a>

Build Elements from Parser Events:

use xml::{Parser, ElementBuilder};
let mut p = xml::Parser::new();
let mut e = xml::ElementBuilder::new();
p.feed_str("<a href='//example.com'/>");
for elem in p.filter_map(|x| e.handle_event(x)) {
 match elem {
 Ok(e) => println!("{}", e),
 Err(e) => println!("{}", e),
 }
}

License

This project is MIT licensed. Please see the COPYING file for more information.

Build Status

веселые картинки развлекательные гифки интресные факты смешные видео смешные истории из соцсетей

Dependents

See all dependents

GitHub Repository

Florob/RustyXML Florob/RustyXML

A XML parser written in Rust

Language: Rust

Created: July 28, 2013 16:39

Last updated: April 01, 2015 02:16

Last pushed: April 01, 2015 01:56

Size: 891 KB

Stars: 33

Forks: 8

Watchers: 5

Open issues: 0

Top Contributors

Florob

Releases

  • 0.1.0 - April 01, 2015 02:01

Related Projects

allegro_font-sys 0.0.13
Allegro 5 font addon Rust binding
Cargo - Rust - Zlib - Updated 1 day ago - 18 stars
bassert 0.0.4
A Better Assert macro This macro will print out the values of each side of an expression and als...
Cargo - Rust - MIT - Updated 3 months ago - 2 stars
bchannel 0.0.6
A better channel API
Cargo - Rust - MIT - Updated 6 days ago - 2 stars
cppStream 0.1.1
a wrapper brings `<<` and `>>` operator to rust's writer/reader/stream like what C++ did
Cargo - Rust - MIT - Updated 3 months ago - 1 stars
flate2 0.2.4
Bindings to miniz.c for DEFLATE compression and decompression exposed as Reader/Writer streams. C...
Cargo - C - Other - Updated 1 day ago - 13 stars
веселые картинки развлекательные гифки интресные факты смешные видео смешные истории из соцсетей