# xmlDecode

    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)

### Namespace processing

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.

### Unordered structure

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" }
      ]
    }

### Ordered structure

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" ] }
      ]
    }

## Parameters

1. text — XML text to decode.
2. flags — optional text where each character is a flag.
3. namespaces — optional dictionary with namespace URI to prefix mappings.

## Returns

- the decoded value or `null` if parsing failed.