Trait minidom_ext::AttributeElementExt[][src]

pub trait AttributeElementExt {
    fn try_attribute<F>(&self, attr_name: &str) -> Result<F, Error>
    where
        F: FromStr,
        F::Err: Error + Send + Sync + 'static
; fn attribute<F>(&self, attr_name: &str) -> Option<F>
    where
        F: FromStr,
        F::Err: Error + Send + Sync + 'static
, { ... } }
Expand description

Get an attribute from an element.

Required methods

Try to get an attribute from its name and return a Result.

The type of the return value is chosen by the caller, as long as this type can be parsed from &str.

Provided methods

Get an attribute from its name if present and return a Option.

The type of the return value is chosen by the caller, as long as this type can be parsed from &str.

Implementations on Foreign Types

Implementation of AttributeElementExt for Element gives you access to the attribute’s value of an XML element. For example, the id’s value of this XML element <tag id="value" />.

use minidom::Element;
use minidom_ext::AttributeElementExt;

let xml: &'static str = r#"<root id="42" />"#;
let root: Element = xml.parse().unwrap();
let id: u64 = root.try_attribute("id").unwrap();
assert_eq!(42, id);

Implementors