[][src]Function magnesium::skip_empty_text_elements

#[must_use]pub fn skip_empty_text_elements<'s>(
    el: XmlElement<'s>
) -> Option<XmlElement<'s>>

Filters out XmlElement::Text(t) when t is only whitespace.

If t is more than just whitespace it is unaffected.

For use with filter_map calls on an ElementIterator.

let iter = ElementIterator::new("").filter_map(skip_empty_text_elements);
for element in iter {
  println!("{:?}", element);
}

Failure

  • If the input is XmlElement::Text and the contained text becomes an empty string after calling trim.