- Our Customers
- Who is using it?
- What are they saying?
- Getting Started
- The Basics
- Sample Templates
- Tips & Tricks
- For Advanced Users
- User Guide
- Contact Us
- Technical Support
Email Templates includes support for XML. XML Documents can be searched for elements and attributes that can be inserted into your message. A short example of a valid XML Document follows:
<?xml version ="1.0" ?> <order> <fruit> <apples> <cost currency="US">1.00</cost> <color>red</color> </apples> </fruit> </order>
Please note that this is a very simple representation of an XML document. The message containing the XML document may contain other text as well. Email Templates will interpret everything between the first "<" and the last ">" as XML. The initial <?xml ?> tag shown in this example is not always present, and most XML documents are likely to be much more complex.
A new element in Email Templates, the XML element, can be used to search this document. The XML element implements a subset of the XML XPath specification, allowing you to point to specific elements in the XML document. It is used in you template as follows:
The path is a series of one or more element accessors separated by a period. You can use a name of an element or a number of an element as possible values for an element accessor. For a simple example, we will show you how to get the value of the element "color":
If used in a template, you would get the value:
As mentioned earlier, you can also use a number as an element accessor. This number indicates the position of the current element accessor in the parent element. From our example, note that "color" is the second element accessor in "apple" (the first is "cost"). You could call the same value by doing the following:
&xml.order.fruit.apples.2; produces: red
Along the same lines, all of the following are valid:
&xml.order.fruit.apples.2; produces: red &xml.order.1.apples.2; produces: red &xml.order.1.1.2; produces: red
Please note that the first element accessor must be specified by its name.
You may also search for attributes of an element accessor. In our example, "currency" is an attribute of the element accessor "cost", with a value of "US". Attributes are specified by a "@" sign following the corresponding element accessor. In our example:
would show up as
The same rules apply for access attributes of element accessors: You may specify the path based on the name of the element accessor or its number.