Function parsercher::search_tag_from_name[][src]

pub fn search_tag_from_name(dom: &Dom, name: &str) -> Option<Vec<Tag>>
Expand description

Returns Tag structures with a tag name equal to name from the Dom structure tree.

Examples

Get only the h2 tag from the following HTML.

<body>
   <h1 class="h1">section1</h1>
   <h2 class="h2">section2</h2>
   <h3 class="h3">section3</h3>
</body>
if let Some(tags) = parsercher::search_tag_from_name(&dom, "h2") {
    println!("{:#?}", tags);
}

output:

[
    Tag {
        name: "h2",
        attr: Some(
            {
                "class": "h2",
            },
        ),
        terminated: false,
        terminator: false,
    },
]