pub struct Attribute<'input> { /* private fields */ }
Expand description
An attribute.
Implementations
sourceimpl<'input> Attribute<'input>
impl<'input> Attribute<'input>
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 range(&self) -> Range<usize>
pub fn range(&self) -> Range<usize>
Returns attribute’s name range in bytes in the original document.
You can calculate a human-readable text position via Document::text_pos_at.
<e attr='value'/>
^
sourcepub fn value_range(&self) -> Range<usize>
pub fn value_range(&self) -> Range<usize>
Returns attribute’s value range in bytes in the original document.
You can calculate a human-readable text position via Document::text_pos_at.
<e attr='value'/>
^
Trait Implementations
Auto Trait Implementations
impl<'input> RefUnwindSafe for Attribute<'input>
impl<'input> Send for Attribute<'input>
impl<'input> Sync for Attribute<'input>
impl<'input> Unpin for Attribute<'input>
impl<'input> UnwindSafe for Attribute<'input>
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