Struct roxmltree::Attribute

source ·
pub struct Attribute<'d> { /* private fields */ }
Expand description

An attribute.

Implementations

Returns attribute’s namespace URI.

Examples
let doc = roxmltree::Document::parse(
    "<e xmlns:n='http://www.w3.org' a='b' n:a='c'/>"
).unwrap();

assert_eq!(doc.root_element().attributes()[0].namespace(), None);
assert_eq!(doc.root_element().attributes()[1].namespace(), Some("http://www.w3.org"));

Returns attribute’s name.

Examples
let doc = roxmltree::Document::parse(
    "<e xmlns:n='http://www.w3.org' a='b' n:a='c'/>"
).unwrap();

assert_eq!(doc.root_element().attributes()[0].name(), "a");
assert_eq!(doc.root_element().attributes()[1].name(), "a");

Returns attribute’s value.

Examples
let doc = roxmltree::Document::parse(
    "<e xmlns:n='http://www.w3.org' a='b' n:a='c'/>"
).unwrap();

assert_eq!(doc.root_element().attributes()[0].value(), "b");
assert_eq!(doc.root_element().attributes()[1].value(), "c");

Returns attribute’s name position in bytes in the original document.

You can calculate a human-readable text position via Node::text_pos_from.

<e attr='value'/>
   ^

Returns attribute’s value position in bytes in the original document.

You can calculate a human-readable text position via Node::text_pos_from.

<e attr='value'/>
         ^

Trait Implementations

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

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 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.