Expand description
This crate provides very a simplistic iterator for stepping over XML data.
Only requires core, doesn’t allocate, doesn’t use unsafe.
The processing is quite simplistic, and the iterator will simply fail and end the iteration if there’s a problem. This doesn’t do any special character replacement for you.
The crate is intended for when you have a fairly basic XML file that is
assumed to be “non-hostile”, and you just need to walk through and scrape
the data. For example, when parsing
gl.xml
or
vk.xml.
§Example Usage
use magnesium::*;
let xml_string = r#"
<?xml version="1.0" encoding="UTF-8"?>
<!-- just imagine we had a whole file here -->
<registry>
<enums namespace="Graphics" group="Polygon">
<enum value="0" name="GRAPHICS_POINTS"/>
<enum value="1" name="GRAPHICS_LINES"/>
</enums>
</registry>
"#;
for element in ElementIterator::new(xml_string) {
println!("{:?}", element);
}Structs§
- Element
Iterator - An iterator to walk the elements of some XML data.
- TagAttribute
- The output of a
TagAttributeIterator. - TagAttribute
Iterator - Iterator to walk through a
StartorEmptytag’s attribute string.
Enums§
- XmlElement
- An element within an XML structure.
Functions§
- skip_
comments - Filters out
XmlElement::Comment(_). - skip_
empty_ text_ elements - Filters out
XmlElement::Text(t)whentis only whitespace. - trim_
text - Applies
str::trimto aTextelement. No effect otherwise.