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
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.
Fields
attrs: &'s strAttribute string, parse this with a
TagAttributeIterator.
EndTag
Closes the StartTag of the same name.
Eg: </books>
EmptyTag
An “empty” tag has no inner content, just attributes.
Eg: <enum name="GRAPHICS_POLYGON value="0x0001"/>
Fields
attrs: &'s strThe tag’s attribute string.
Parse this with a
TagAttributeIterator.
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
Unwraps a Text variant into the inner &str value.
§Panics
If the variant isn’t Text this will panic.
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 more