Function magnesium::skip_empty_text_elements
source · pub fn skip_empty_text_elements(el: XmlElement<'_>) -> Option<XmlElement<'_>>
Expand description
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 callingtrim
.