pub struct Attribute<'d> { /* private fields */ }
Expand description
An attribute.
Implementations
sourceimpl<'d> Attribute<'d>
impl<'d> Attribute<'d>
sourcepub fn namespace(&self) -> Option<&str>
pub fn namespace(&self) -> Option<&str>
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"));
sourcepub fn name(&self) -> &str
pub fn name(&self) -> &str
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");
sourcepub fn value(&self) -> &str
pub fn value(&self) -> &str
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");
sourcepub fn pos(&self) -> usize
pub fn pos(&self) -> usize
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'/>
^
sourcepub fn value_pos(&self) -> usize
pub fn value_pos(&self) -> usize
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
Auto Trait Implementations
impl<'d> RefUnwindSafe for Attribute<'d>
impl<'d> !Send for Attribute<'d>
impl<'d> !Sync for Attribute<'d>
impl<'d> Unpin for Attribute<'d>
impl<'d> UnwindSafe for Attribute<'d>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more