value xmlDecode(text, flags, namespaces)
Parse an application/xml encoded text (XML) into a value.
Flags:
Flag | Description |
---|---|
"0" | Return an unordered structure, the default |
"1" | Return an ordered structure |
"i" | Exclude ignorable whitespace |
"n" | Process namespaces, results in qualified element and attribute names (with prefixes) |
When enabled the element and attribute names are qualified with a prefix, i.e x:html
, unless itβs the default namespace.
The prefixes will be taken from the namespace dictionary, from the input XML, or automatically generated.
The namespaces used in the resulting structure are stored with the key "#xmlns"
key in the document (root) dictionary.
An irreversible structure where element order is lost. Use to easily access text only elements by name.
An "#text"
key is added to an element which has both text and element children.
<ul> text <li class="active">first</li> <li>second</li> </ul>
Resulting dictionary structure:
{ "#xmlns": { "http://www.w3.org/1999/xhtml" : "" }, "#text": "text", "ul": [ { "li": { "@class": "active", "#text": "first" }, { "li": "second" } ] }
A reversible structure where element order is maintained.
<ul> text <li class="active">first</li> <li>second</li> </ul>
Resulting dictionary structure:
{ "#xmlns": { "http://www.w3.org/1999/xhtml" : "" }, "name": "ul", "children": [ "text", { name: "li", "@class": "active", "children": [ "first" ] }, { name: "li", "children": [ "second" ] } ] }
null
if parsing failed.