rquery

Crates.iorquery
lib.rsrquery
version0.4.1
sourcesrc
created_at2015-11-02 00:18:50.411578
updated_at2018-02-23 10:00:32.211746
descriptionA simple implementation of a HTML/XML DOM tree which allows simple operations like querying by CSS selectors, makes dealing with XML files less painful.
homepagehttps://github.com/yggie/rquery
repositoryhttps://github.com/yggie/rquery
max_upload_size
id3351
size32,661
Bryan Yap (yggie)

documentation

https://yggie.github.io/rquery/rquery

README

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");
}
Commit count: 32

cargo fmt