XML File Data Source

You can use an XML file as a data source for templating. XML file must be well-formed and have one root element.

The system reads your data as a set of rows (read more here: Data Sources). However, for the XML format system always threats all document's structure as one data row. We use simplified XML parsing rules and don't support XML Schema:

  1. If a tag contains a simple value and doesn't contain other tags, then the value will be treated as a primitive string, number, boolean or ISO 8601 date.
  2. If a tag contains other tags, then there could an ambiguous situation.

    For example:

    <?xml version="1.0" encoding="UTF-8"?>
    <root>
        <elem1>
            <nested>value</nested>
        </elem1>
    </root>

    The elem1 tag can be either a list with one element or an entity with just one field. At the moment, this situation is always resolved into the entity with one field.

  3. If a tag contains attributes then it is always treated as an entity with fields. Also, the attributes will be joined with nested tags containing values, that is, it will be one set of named values.

    For example:

    <?xml version="1.0" encoding="UTF-8"?>
    <root>
        <object1 attrProp1="value1">
            <tagProp1>value2</tagProp1>
            <tagProp2>value3</tagProp2>
        </object1>
    </root>

    Will be parsed into entity:

    object1:
      attrProp1: value1,
      tagProp1: value2,
      tagProp2: value3
  4. If a tag has attributes, but contains only simple value and doesn't contain other tags, then it is parsed into an entity with fields anyway. Also, it's simple value will be accessible through tagValue key.

    For example:

    <?xml version="1.0" encoding="UTF-8"?>
    <root>
        <object1 attrProp1="value1">value2</object1>
    </root>

    Here is an example of an XML data file:

    data.xml