[][src]Struct roxmltree::Attribute

pub struct Attribute<'d> { /* fields omitted */ }

An attribute.

Methods

impl<'d> Attribute<'d>[src]

pub fn namespace(&self) -> Option<&str>[src]

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"));

pub fn name(&self) -> &str[src]

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");

pub fn value(&self) -> &str[src]

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");

pub fn range(&self) -> Range<usize>[src]

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'/>
   ^

pub fn value_range(&self) -> Range<usize>[src]

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

impl<'d> PartialEq<Attribute<'d>> for Attribute<'d>[src]

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0
[src]

This method tests for !=.

impl<'d> Debug for Attribute<'d>[src]

Auto Trait Implementations

impl<'d> !Send for Attribute<'d>

impl<'d> !Sync for Attribute<'d>

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.