pub enum XmlElement<'s> {
    StartTag {
        name: &'s str,
        attrs: &'s str,
    },
    EndTag {
        name: &'s str,
    },
    EmptyTag {
        name: &'s str,
        attrs: &'s str,
    },
    Text(&'s str),
    Comment(&'s str),
}
Expand description

An element within an XML structure.

Variants§

§

StartTag

Fields

§name: &'s str

Name of this tag.

§attrs: &'s str

Attribute string, parse this with a TagAttributeIterator.

An opening tag with a name and some attributes.

Eg: <books attr1="val1">

If the XML is well formed, then there will be an EndTag with a matching name later on. In between there can be any number of sub-entries.

§

EndTag

Fields

§name: &'s str

Name of the tag being closed.

Closes the StartTag of the same name.

Eg: </books>

§

EmptyTag

Fields

§name: &'s str

The tag’s name.

§attrs: &'s str

The tag’s attribute string.

Parse this with a TagAttributeIterator.

An “empty” tag has no inner content, just attributes.

Eg: <enum name="GRAPHICS_POLYGON value="0x0001"/>

§

Text(&'s str)

Text between tags.

If there’s a “CDATA” entry it is parsed as a Text element.

§

Comment(&'s str)

Text between <!-- and -->.

Implementations§

source§

impl<'s> XmlElement<'s>

source

pub fn unwrap_start_tag(&self) -> (&'s str, &'s str)

Unwraps a StartTag variant into the inner (name, attrs) pair.

Panics

If the variant isn’t StartTag this will panic.

source

pub fn unwrap_end_tag(&self) -> &'s str

Unwraps an EndTag variant into the inner name.

Panics

If the variant isn’t EndTag this will panic.

source

pub fn unwrap_text(&self) -> &'s str

Unwraps a Text variant into the inner &str value.

Panics

If the variant isn’t Text this will panic.

source

pub fn unwrap_comment(&self) -> &'s str

Unwraps a Comment variant into the inner &str value.

Panics

If the variant isn’t Comment this will panic.

Trait Implementations§

source§

impl<'s> Clone for XmlElement<'s>

source§

fn clone(&self) -> XmlElement<'s>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'s> Debug for XmlElement<'s>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'s> Hash for XmlElement<'s>

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<'s> PartialEq<XmlElement<'s>> for XmlElement<'s>

source§

fn eq(&self, other: &XmlElement<'s>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'s> Copy for XmlElement<'s>

source§

impl<'s> Eq for XmlElement<'s>

source§

impl<'s> StructuralEq for XmlElement<'s>

source§

impl<'s> StructuralPartialEq for XmlElement<'s>

Auto Trait Implementations§

§

impl<'s> RefUnwindSafe for XmlElement<'s>

§

impl<'s> Send for XmlElement<'s>

§

impl<'s> Sync for XmlElement<'s>

§

impl<'s> Unpin for XmlElement<'s>

§

impl<'s> UnwindSafe for XmlElement<'s>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.