Free cookie consent management tool by TermsFeed

toxml() Function

On This Page

Converts a value to its equivalent XML form.

Parameters

toxml( value, format, name, namespace )

Keyword Type Description

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.

Returns

Text

Using the function

The following sections cover important details about the toxml() function.

Supported data types

The toxml() function supports primitive system data types, custom data types, and the following complex system data types:

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

XML 1.0 character restrictions

The toxml() function generates XML that conforms to the XML 1.0 standard. XML 1.0 restricts the characters that can appear in a document. If the value passed to toxml() contains characters that are not permitted by XML 1.0, the function will return an error.

For example, most control characters in the #x0–#x1F range are not valid in XML 1.0. To avoid errors, remove or replace any invalid characters from your data before passing it to toxml().

See the Character Range production in the XML 1.0 specification for the full list of valid characters.

Examples

The following examples demonstrate the toxml() function.

To experiment with examples, copy and paste the expression into an expression rule and click TEST RULE to see the output.

Convert a data type to XML

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

Returns

1
2
3
4
<a:PagingInfo xmlns:a="http://www.appian.com/ae/types/2009">
 <startIndex>1</startIndex>
 <batchSize>10</batchSize>
</a:PagingInfo>

Convert a list to a single-root XML document

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.

1
2
3
4
a!localVariables(
  local!data:{​{ id: 1, value: "First value"}, { id: 2, value: "Second Value"}},
  "<root>" & toxml(local!data) & "</root>"
)

Returns

1
2
3
4
<root>
  <a:Dictionary xmlns:a="http://www.appian.com/ae/types/2009" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><id xsi:type="xsd:int">1</id><value xsi:type="xsd:string">First value</value></a:Dictionary>
  <a:Dictionary xmlns:a="http://www.appian.com/ae/types/2009" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><id xsi:type="xsd:int">2</id><value xsi:type="xsd:string">Second Value</value></a:Dictionary>
</root>

Feature compatibility

The table below lists this function's compatibility with various features in Appian.
Feature Compatibility Note
Portals Partially compatible

Can be used with Appian Portals if it is connected using an integration and web API.

Offline Interfaces Partially compatible

Can be used with offline interfaces if loaded at the top of the interface.

Sync-Time Custom Record Fields Incompatible
Real-Time Custom Record Fields Incompatible

Custom record fields that evaluate in real time must be configured using one or more Custom Field functions.

Process Reports Incompatible

Cannot be used to configure a process report.

Process Events Partially compatible

If autoscale is enabled, can be used to configure a supported process event node (such as a start event or timer event).

Process Autoscaling Compatible

Can be used in autoscaled processes.

Event Consumer Filter Conditions Incompatible

Cannot be used in filter conditions.

Event Consumer Event Handlers Incompatible

Cannot be used in event handler expressions.

Feedback