Signature
DValue xml_decode(String s)
Parameters
Parses a simple XML document into a structured DValue.
xml_decode() parses a compact XML subset. It does not validate schemas, DTDs, namespaces, or document types. It parses the first root element and returns the same structural element shape accepted by xml_encode().
Try the live example in the XML demo.
Return shape:
Example:
CDATA and numeric entities are folded into text:
Supported parser features:
elements
attributes with quoted values
self-closing tags
text nodes
XML entities such as
&,<,>,", and'decimal and hexadecimal numeric entities
comments, processing instructions, and CDATA sections
Whitespace-only text between child elements is ignored. Mixed non-empty text is concatenated into node["text"].
Malformed XML raises a request-visible runtime error.
Example
DValue node = xml_decode("<root><name>Ada</name></root>");
print(node.is_array() ? "xml\n" : "empty\n");
xml