# Create Container from XML

This statement is used to create a container from XML text. You supply the name of the container to be created. If the named container already exists, it is overwritten. The XML text is supplied in a named variable. XML Namespaces are completely ignored. XML prefixes are treated as being part of the item name.

All text fields can contain any of the escape sequences defined in Escape Sequences.

Upon success the action test state will be set to true. If the container name is invalid or if there is an error parsing the XML text, the action test state will be set to false.

A created container is always an Object. Arrays are automatically created when there is more than one occurrence of a named item. For this reason you may have to use the Extract Data from Container statement with data type tags enabled to determine if an item is an Array or Object.

Attributes are stored as items in an object and by default their names are prefixed with an @ character. You can supply an alternate prefix.

Text found within an object is stored as an item with the name #text. An alternate for this text tag can be supplied.

All returned items are by default Objects. If you specify the Unembed simple text items setting, Objects which only contain a text item will have the text item replace the containing object.

Sample XML:

    <metadata>
    <string id="test">s1</string>
    <string>s2</string>
    <qual>123</qual>
    </metadata>

Object created when Unembed simple text items is off:

    {
      "metadata" : {
        "qual" : {
          "#text" : "123"
        },
        "string" : [
          {
            "@id" : "test",
            "#text" : "s1"
          },
          {
            "#text" : "s2"
          }
        ]
      }
    }

Object created when Unembed simple text items is on:

    {
      "metadata" : {
        "qual" : "123",
        "string" : [
          {
            "@id" : "test",
            "#text" : "s1"
          },
          "s2"
        ]
      }
    }

Containers

Directed Paths