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
Provided methods
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);