# `RustyXML.SimpleForm`
[🔗](https://github.com/jeffhuen/rustyxml/blob/v0.2.3/lib/rusty_xml/simple_form.ex#L1)

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_name` is a string
  * `attributes` is a list of `{name, value}` tuples
  * `children` is 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"]}]}}

# `element`
[🔗](https://github.com/jeffhuen/rustyxml/blob/v0.2.3/lib/rusty_xml/simple_form.ex#L23)

```elixir
@type element() :: {String.t(), [{String.t(), String.t()}], [element() | String.t()]}
```

# `parse_stream`
[🔗](https://github.com/jeffhuen/rustyxml/blob/v0.2.3/lib/rusty_xml/simple_form.ex#L57)

```elixir
@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_string`
[🔗](https://github.com/jeffhuen/rustyxml/blob/v0.2.3/lib/rusty_xml/simple_form.ex#L36)

```elixir
@spec parse_string(
  String.t(),
  keyword()
) :: {:ok, element()} | {:error, any()}
```

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`)

---

*Consult [api-reference.md](api-reference.md) for complete listing*
