#dom #xml #jquery

rquery

A simple implementation of a HTML/XML DOM tree which allows simple operations like querying by CSS selectors, makes dealing with XML files less painful

10 releases

Uses old Rust 2015

0.4.1 Feb 23, 2018
0.4.0 Oct 31, 2017
0.3.2 Apr 7, 2017
0.3.1 Oct 29, 2016
0.1.2 Nov 2, 2015

#5 in #jquery

Download history 56/week @ 2024-02-25 9/week @ 2024-03-03 9/week @ 2024-03-10 6/week @ 2024-03-17

80 downloads per month
Used in cargo-kcov

MIT license

22KB
432 lines

rquery

Build Status docs crates.io license

A simple implementation of a HTML/XML DOM tree which allows simple operations like querying by CSS selectors, makes dealing with XML files less painful.

Example

extern crate rquery;

use rquery::Document;

fn main() {
  let document = Document::new_from_xml_file("tests/fixtures/sample.xml").unwrap();

  let title = document.select("title").unwrap();
  assert_eq!(title.text(), "Sample Document");
  assert_eq!(title.attr("ref").unwrap(), "main-title");

  let item_count = document.select_all("item").unwrap().count();
  assert_eq!(item_count, 2);

  let item_titles = document.select_all("item > title").unwrap()
    .map(|element| element.text().clone())
    .collect::<Vec<String>>()
    .join(", ");
  assert_eq!(item_titles, "Another Sample, Other Sample");
}

Dependencies

~350KB