Enum magnesium::XmlElement
source · 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
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
Closes the StartTag
of the same name.
Eg: </books>
EmptyTag
Fields
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>
impl<'s> XmlElement<'s>
sourcepub fn unwrap_start_tag(&self) -> (&'s str, &'s str)
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.
sourcepub fn unwrap_end_tag(&self) -> &'s str
pub fn unwrap_end_tag(&self) -> &'s str
sourcepub fn unwrap_text(&self) -> &'s str
pub fn unwrap_text(&self) -> &'s str
sourcepub fn unwrap_comment(&self) -> &'s str
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>
impl<'s> Clone for XmlElement<'s>
source§fn clone(&self) -> XmlElement<'s>
fn clone(&self) -> XmlElement<'s>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<'s> Debug for XmlElement<'s>
impl<'s> Debug for XmlElement<'s>
source§impl<'s> Hash for XmlElement<'s>
impl<'s> Hash for XmlElement<'s>
source§impl<'s> PartialEq<XmlElement<'s>> for XmlElement<'s>
impl<'s> PartialEq<XmlElement<'s>> for XmlElement<'s>
source§fn eq(&self, other: &XmlElement<'s>) -> bool
fn eq(&self, other: &XmlElement<'s>) -> bool
self
and other
values to be equal, and is used
by ==
.