Function parsercher::search_text_from_tag_children[][src]

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

Returns texts of the child of the Tag structure for which needle is a sufficient condition from the Dom structure tree.

Examples

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

<ol>
   <li class="target">first</li>
   <li>second</li>
   <li class="target">therd</li>
</ol>
let mut needle = Tag::new("li");
let mut attr = HashMap::new();
attr.insert("class".to_string(), "target".to_string());
needle.set_attr(attr);
if let Some(texts) = parsercher::search_text_from_tag_children(&dom, &needle) {
    assert_eq!(texts.len(), 2);
    assert_eq!(texts[0], "first".to_string());
    assert_eq!(texts[1], "therd".to_string());
}