Handlebars Helper Function: buildRowSetFromXml

Loads XML data into a rowset by using an XPath expression.

Availability 

This helper is available in the Winter ’27 release of Marketing Cloud Next.

Syntax 

1{{buildRowSetFromXml xmlData xpathExpression returnEmptyOnError=true|false}}

Parameters 

ParameterTypeDescription
xmlDataStringRequired. The XML data to parse.
xpathExpressionStringRequired. The XPath expression that selects nodes from xmlData.
returnEmptyOnErrorBooleanRequired. If true, returns an empty rowset when parsing or XPath evaluation fails. If false, throws an exception. Specify as a named parameter.

Return Value 

The function returns a rowset that contains the XML nodes selected by xpathExpression. Each row includes the node value, XML, and any attributes found in the selected nodes.

Usage Example 

This example selects the Flight nodes from an XML string.

1{{#set flightsXml}}
2  <root>
3    <Flight origin="IND" dest="NYC">100.00</Flight>
4    <Flight origin="IND" dest="LAX" carrier="UAL">200.00</Flight>
5    <Flight origin="IND" dest="SEA">500<PerBagSurcharge>25</PerBagSurcharge></Flight>
6  </root>
7{{/set}}
8
9{{#each (buildRowSetFromXml flightsXml "//Flight" returnEmptyOnError=false)}}
10  {{Origin_att}}
11  to
12  {{Dest_att}}:
13  {{Value}}
14{{/each}}

The example produces this output:

1IND to NYC: 100.00
2IND to LAX: 200.00
3IND to SEA: 500