Parse XML into a simple tree of nested tuples.
Drop-in replacement for Saxy.SimpleForm.
The simple form represents XML as:
{tag_name, attributes, children}Where:
tag_nameis a stringattributesis a list of{name, value}tupleschildrenis a list of child elements or text strings
Examples
RustyXML.SimpleForm.parse_string("<root><item id=\"1\">text</item></root>")
#=> {:ok, {"root", [], [{"item", [{"id", "1"}], ["text"]}]}}
Summary
Types
Functions
@spec parse_stream( Enumerable.t(), keyword() ) :: {:ok, element()} | {:error, any()}
Parse a stream of XML chunks into simple form.
Accumulates all chunks in Rust, then validates, indexes, and builds the SimpleForm tree in one pass. Minimal BEAM memory during accumulation.
Examples
File.stream!("large.xml", [], 64 * 1024)
|> RustyXML.SimpleForm.parse_stream()
#=> {:ok, {"root", [], [...]}}
Parse an XML string into simple form.
Returns {:ok, root_element} on success, {:error, exception} on failure.
Options
:cdata_as_characters- Merge CDATA into text content (default:true)