Crate magnesium

Source
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§

ElementIterator
An iterator to walk the elements of some XML data.
TagAttribute
The output of a TagAttributeIterator.
TagAttributeIterator
Iterator to walk through a Start or Empty tag’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) when t is only whitespace.
trim_text
Applies str::trim to a Text element. No effect otherwise.