toxml() Function

Converts a value to its equivalent XML form.


toxml( value, format, name, namespace )

value: (Any Type) The value or variable (PV, ACP) to be converted to XML.

format: (Boolean) Whether or not to format the result. If true, the resultant XML is formatted with line breaks and indenting, otherwise it uses a compact notation. If not given, the result is unformatted XML.

name: (Text) The name to use as the root element name in the resultant XML. If not given, the name of the data type of the variable passed as the value parameter is used.

namespace: (Text) The namespace to use as the default namespace in the resultant XML. If not given, the namespace of the data type of the variable passed as the value parameter is used.




This function supports primitive system data types, custom data types, and the following complex system data types: LabelValue, LabelValueTable, PagingInfo, SortInfo, and DataSubset.

The XML structure for Complex System Data Types and Appian objects is not guaranteed to remain the same from release to release.


You can copy and paste these examples into the Expression Rule Designer to see how this works.

toxml(a!paginginfo(startIndex: 1, batchSize: 10))


  <a:PagingInfo xmlns:a="">

A well-formed XML document has a single root element. When you pass a list into toxml(), you get an XML snippet of multiple elements. To end up with a single-root XML document when passing in a list, use a parent-level xml element.

By wrapping it with a root element, you end up with a well-formed single-root XML document.

  local!data:{‚Äč{ id: 1, value: "First value"}, { id: 2, value: "Second Value"}},
  "<root>" & toxml(local!data) & "</root>"


  <a:Dictionary xmlns:a="" xmlns:xsd="" xmlns:xsi=""><id xsi:type="xsd:int">1</id><value xsi:type="xsd:string">First value</value></a:Dictionary>
  <a:Dictionary xmlns:a="" xmlns:xsd="" xmlns:xsi=""><id xsi:type="xsd:int">2</id><value xsi:type="xsd:string">Second Value</value></a:Dictionary>

On This Page