Struct glifparser::glif::xml::Element

source ·
pub struct Element {
    pub prefix: Option<String>,
    pub namespace: Option<String>,
    pub namespaces: Option<Namespace>,
    pub name: String,
    pub attributes: IndexMap<String, String, RandomState>,
    pub children: Vec<XMLNode, Global>,
}
Expand description

Represents an XML element.

Fields§

§prefix: Option<String>

This elements prefix, if any

§namespace: Option<String>

This elements namespace, if any

§namespaces: Option<Namespace>

The full list of namespaces, if any

The Namespace type is exported from the xml-rs crate.

§name: String

The name of the Element. Does not include any namespace info

§attributes: IndexMap<String, String, RandomState>

The Element attributes

By default, this is a HashMap, but if the optional “attribute-order” feature is enabled, this is an IndexMap, which will retain item insertion order.

§children: Vec<XMLNode, Global>

Children

Implementations§

Create a new empty element with given name

All other fields are empty

Parses some data into a list of XMLNodes

This is useful when you want to capture comments or processing instructions that appear before or after the root node

Parses some data into an Element

Writes out this element as the root element in an new XML document

Writes out this element as the root element in a new XML document using the provided configuration

Find a child element with the given name and return a reference to it.

Both &str and String implement ElementPredicate and can be used to search for child elements that match the given element name with .get_child("element_name"). You can also search by ("element_name", "tag_name") tuple.

Note: this will only return Elements. To get other nodes (like comments), iterate through the children field.

Find a child element with the given name and return a mutable reference to it.

Find a child element with the given name, remove and return it.

Returns the inner text/cdata of this element, if any.

If there are multiple text/cdata nodes, they will be all concatenated into one string.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. 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
Compare self to key and return true if they are equal.

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
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.