Enum xml_doc::Node [−][src]
pub enum Node {
Element(Element),
Text(String),
Comment(String),
CData(String),
PI(String),
DocType(String),
}Expand description
Represents an XML node.
Variants
Element(Element)Tuple Fields of Element
0: ElementText(String)Tuple Fields of Text
0: StringComment(String)Tuple Fields of Comment
0: StringCData(String)Tuple Fields of CData
0: StringPI(String)Tuple Fields of PI
0: StringDocType(String)Tuple Fields of DocType
0: StringImplementations
Useful to use inside filter_map.
use xml_doc::{Document, Element};
let mut doc = Document::parse_str(r#"<?xml version="1.0" encoding="UTF-8"?>
<config>
Random Text
<max>1</max>
</config>
"#).unwrap();
let elems: Vec<Element> = doc
.root_element()
.unwrap()
.children(&doc)
.iter()
.filter_map(|n| n.as_element())
.collect();Returns content if node is Text, CData, or PI.
If node is Element, return Element::text_content()
Implementation of Node.textContent