# xml/parse Parse an XML document string into a Deft value. Compact by default; `%{ :compact false }` (or `:tree`) returns document-order tree nodes. ## Syntax
[xml/parse $s ?opts]
## Parameters - `$s` — XML document text (string, valid UTF-8) - `$opts` — optional shape selector: `%{ :compact false }` for the tree shape; the keywords `:tree` / `:compact` are shorthand ## Examples
set doc [xml/parse "<order id=\"A1\"><customer>Ada</customer></order>"]
[get [get $doc "order"] "@id"]       # => "A1"
[get [get $doc "order"] "customer"]  # => "Ada"

# Repeated child elements become a vector in document order
set feed [get [xml/parse "<feed><entry>a</entry><entry>b</entry></feed>"] "feed"]
[get $feed "entry"]                  # => @{ "a" "b" }

# Tree shape keeps order, comments, and processing instructions
[xml/parse "<a/>" :tree]
# => %{ :name "a" :attributes %{} :children @{} }
## Returns Compact shape: a map keyed by the root element name, with `"@attr"` keys, the `"#text"` key, leaf elements collapsed to their character data, and repeated child names as vectors. Tree shape: `%{ :name :attributes :children }`, where `:children` holds text strings, element maps, `%{ :comment "..." }`, and `%{ :target "..." :data "..." }` in document order. Malformed input returns `%Err{ :message "line N, column M: ..." }`. The parser enforces well-formedness, expands predefined/numeric references and internal-DTD entity declarations with limits, and never reads external DTDs or external entities. Namespace prefixes are kept verbatim. ## See Also `xml/load`, `xml/stringify`, `xml/pretty`, `xml/escape`, `xml/unescape`