XML

Attributes

By default each field is generated as a separate child element. To generate the value as an attrbute of the parent element, name the field starting with "@". For example: fields with name "@id" and "name" would yield:

<person id="1"> <name>Joe Smith</name> </person>

Elements with attributes and a value

If you need to generate an element with attributes and a text value like this:

<firstName short="Bob">Robert</firstName>

Then you can use ".$value" as the suffix for the text field. So in this case, the fields would be named:

  • firstName.short => "Bob"
  • firstName.$value => "Robert"

Nesting

If you want to include nested elements in XML output, you can name your fields using dot (".") notation. For example, two fields named "address.city" and "address.state" will result in a value like:

<address> <city>Sparta</city> <state>New Jersey</state> </address>

Chain dots together for deeper nesting. The "@" symbol for attributes should always be on the last token. So for example "address.@street"

Collections

To generate multiple values, simply add brackets containing the number of items you want to generate to the end of the field name.

For example, "friend[3]" would result in values like:

<friend>Joe Smith</friend> <friend>Sally Brown</friend> <friend>Mike Jones</friend>

You can also nest multiple values inside a parent element. For example "friends.friend[3]" would result in a value like: pre

<friends> <friend>Joe Smith</friend> <friend>Sally Brown</friend> <friend>Mike Jones</friend> </friends>

If you would like a random number of values, specify a range in brackets. For example, "friends[2-5]" would result in 2 to 5 values being generated per record

Repeating Elements

To repeat nested elements, use the "Repeating Element" type. For example a Repeating Element field named "friend" and min elements: 2 would yield:

<record> <friend> <first_name>Kathryn</first_name> <last_name>Johnston</last_name> <email>kjohnston0@barnesandnoble.com</email> </friend> <friend> <first_name>Joshua</first_name> <last_name>Burns</last_name> <email>jburns1@youtu.be</email> </friend> </record>