Function parsercher::search_tag[][src]

pub fn search_tag(dom: &Dom, needle: &Tag) -> Option<Vec<Tag>>
Expand description

Returns Tag structures from which the needle is a sufficient condition from the Dom structure tree.

Examples

Get li tags that class attribute value is target from the following HTML.

<ol>
   <li class="target">first</li>
   <li>second</li>
   <li id="third" class="target">therd</li>
</ol>
let mut needle = Tag::new("li");
needle.set_attr("class", "target");
if let Some(tags) = parsercher::search_tag(&dom, &needle) {
    println!("{:#?}", tags);
}

output:

[
    Tag {
        name: "li",
        attr: Some(
            {
                "class": "target",
            },
        ),
        terminated: false,
        terminator: false,
    },
    Tag {
        name: "li",
        attr: Some(
            {
                "id": "third",
                "class": "target",
            },
        ),
        terminated: false,
        terminator: false,
    },
]