Struct victoria_dom::DOM [] [src]

pub struct DOM { /* fields omitted */ }

The HTML DOM type

Methods

impl DOM
[src]

[src]

Construct a new DOM object and parse HTML.

use victoria_dom::DOM;
let dom = DOM::new("<div id=\"title\">Hello</div>");

Important traits for Vec<u8>
[src]

Find all ancestor elements of the current element matching the optional CSS selector and return a Vector of DOM objects of these elements.

use victoria_dom::DOM;
let dom = DOM::new("<html><body><div id=\"title\">Hello</div></body></html>");
let ancestors: Vec<_> = dom.at("div").unwrap().ancestors(None).iter().map(|x| x.tag().unwrap().to_string()).collect();
assert_eq!(ancestors, ["body", "html"]);

[src]

Find first descendant element of the current element matching the CSS selector and return it as a DOM object, or None if none could be found.

[src]

The current element tag name.

[src]

The current element attribute2value map.

[src]

The current element attribute value, or None if there are no attribute with the name or value.

Important traits for Vec<u8>
[src]

Find all child elements of the current element matching the CSS selector and return a Vector of DOM objects of these elements.

use victoria_dom::DOM;
let dom = DOM::new("<div><div id=\"a\">A <span id=\"c\">C</span></div><div id=\"b\">B</div></div>");
let childs: Vec<_> = dom.at("div").unwrap().childs(None).iter().map(|x| x.attr("id").unwrap().to_string()).collect();
assert_eq!(childs, ["a", "b"]);

Important traits for Vec<u8>
[src]

Find all descendant elements of the current element matching the CSS selector and return a Vector of DOM objects of these elements.

use victoria_dom::DOM;
let dom = DOM::new("<div><div id=\"a\"><div id=\"c\">C</div></div><div id=\"b\">B</div></div>");
let elems: Vec<_> = dom.find("div[id]").iter().map(|x| x.attr("id").unwrap().to_string()).collect();
assert_eq!(elems, ["a", "c", "b"]);

[src]

Check if the current element matches the CSS selector.

Important traits for Vec<u8>
[src]

Find all sibling elements after the current element matching the CSS selector and return a Vector of DOM objects of these elements.

use victoria_dom::DOM;
let dom = DOM::new("<div><div id=\"a\"><div id=\"c\">C</div></div><div id=\"b\">B</div></div>");
let elems: Vec<_> = dom.at("div#a").unwrap().following(None).iter().map(|x| x.attr("id").unwrap().to_string()).collect();
assert_eq!(elems, ["b"]);

[src]

Return a DOM object for next sibling element, or None if there are no more siblings.

Important traits for Vec<u8>
[src]

Find all sibling elements before the current element matching the CSS selector and return a Vector of DOM objects of these elements.

use victoria_dom::DOM;
let dom = DOM::new("<div><div id=\"a\"><div id=\"c\">C</div></div><div id=\"b\">B</div></div>");
let elems: Vec<_> = dom.at("div#b").unwrap().preceding(None).iter().map(|x| x.attr("id").unwrap().to_string()).collect();
assert_eq!(elems, ["a"]);

[src]

Return a DOM object for the previous sibling element, or None if there are no more siblings.

[src]

Return a DOM object for the parent of the current element, or None if this element has no parent.

[src]

Render the current element and its content to HTML.

[src]

Extract text content from the current element only (not including child elements) with smart whitespace trimming.

use victoria_dom::DOM;
let dom = DOM::new("<div>foo\n<p>bar</p>baz\n</div>");
assert_eq!(dom.at("div").unwrap().text(), "foo baz");

[src]

Extract text content from the current element only (not including child elements) without smart whitespace trimming.

use victoria_dom::DOM;
let dom = DOM::new("<div>foo\n<p>bar</p>baz\n</div>");
assert_eq!(dom.at("div").unwrap().rtext(), "foo\nbaz\n");

[src]

Extract text content from all descendant nodes of the current element with smart whitespace trimming.

use victoria_dom::DOM;
let dom = DOM::new("<div>foo\n<p>bar</p>baz\n</div>");
assert_eq!(dom.at("div").unwrap().text_all(), "foo bar baz");

[src]

Extract text content from all descendant nodes of the current element without smart whitespace trimming.

use victoria_dom::DOM;
let dom = DOM::new("<div>foo\n<p>bar</p>baz\n</div>");
assert_eq!(dom.at("div").unwrap().rtext_all(), "foo\nbarbaz\n");

[src]

Return content of the current element.

use victoria_dom::DOM;
let dom = DOM::new("<div><b>Test</b></div>");
assert_eq!(dom.at("div").unwrap().content(), "<b>Test</b>");

Trait Implementations

impl Debug for DOM
[src]

[src]

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl !Send for DOM

impl !Sync for DOM