pub struct Attribute<'a, 'input: 'a> { /* private fields */ }
Expand description
An attribute.
Implementations§
source§impl<'a, 'input> Attribute<'a, 'input>
impl<'a, 'input> Attribute<'a, 'input>
sourcepub fn namespace(&self) -> Option<&'a str>
pub fn namespace(&self) -> Option<&'a 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().nth(0).unwrap().namespace(), None);
assert_eq!(doc.root_element().attributes().nth(1).unwrap().namespace(), Some("http://www.w3.org"));
sourcepub fn name(&self) -> &'input str
pub fn name(&self) -> &'input 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().nth(0).unwrap().name(), "a");
assert_eq!(doc.root_element().attributes().nth(1).unwrap().name(), "a");
sourcepub fn value(&self) -> &'a str
pub fn value(&self) -> &'a 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().nth(0).unwrap().value(), "b");
assert_eq!(doc.root_element().attributes().nth(1).unwrap().value(), "c");
sourcepub fn value_storage(&self) -> &StringStorage<'input>
pub fn value_storage(&self) -> &StringStorage<'input>
Returns attribute’s value storage.
Useful when you need a more low-level access to an allocated string.
sourcepub fn position(&self) -> usize
pub fn position(&self) -> usize
Returns attribute’s position in bytes in the original document.
You can calculate a human-readable text position via Document::text_pos_at.
<e attr='value'/>
^
Trait Implementations§
impl<'a, 'input: 'a> Copy for Attribute<'a, 'input>
Auto Trait Implementations§
impl<'a, 'input> Freeze for Attribute<'a, 'input>
impl<'a, 'input> RefUnwindSafe for Attribute<'a, 'input>
impl<'a, 'input> Send for Attribute<'a, 'input>
impl<'a, 'input> Sync for Attribute<'a, 'input>
impl<'a, 'input> Unpin for Attribute<'a, 'input>
impl<'a, 'input> UnwindSafe for Attribute<'a, 'input>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)