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: Element
Text(String)

Tuple Fields of Text

0: String
Comment(String)

Tuple Fields of Comment

0: String
CData(String)

Tuple Fields of CData

0: String
PI(String)

Tuple Fields of PI

0: String
DocType(String)

Tuple Fields of DocType

0: String

Implementations

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

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.