BuildRowSetFromXml()

Loads XML data into a rowset. This function is helpful if you have XML data that you want to programmatically insert into your content. This function is executed at send time for outgoing messages and at load time for CloudPages.

Availability 

Marketing Cloud Engagement ✅ Yes
Marketing Cloud Next ❌ No

Syntax 

1BuildRowSetFromXml(xmlData, xpathExpression, boolReturnEmptyOnError)

The BuildRowSetFromXml() function has three parameters:

  • xmlData (string): Required. The XML data that you want to parse.
  • xpathExpression (string): Required. The XPath expression that parses the source data.
  • boolReturnEmptyOnError (boolean): Required. If false, the function returns an empty rowset when there’s a syntax error in the function or the XPath expression. If true, the function returns an exception when an error occurs.

Usage 

The following nodes in the XML source data don’t return a value:

  • CDATA
  • Comment
  • Document
  • Document Fragments
  • DocumentType
  • Entities
  • Entity References
  • Notation
  • ProcessingInformation
  • Whitespace
  • XmlDeclaration

The rowset also provides a column for each attribute found in any of the nodes. If a node is missing a value for that attribute, the rowset includes an empty value.

1%%[
2Set @sourceXml = "<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
6    <PerBagSurcharge>25</PerBagSurcharge>
7  </Flight>
8</root>"
9
10BuildRowsetFromXml(@xml, '//Flight', 1)
11]%%

The system returns this rowset:

1| Value  | Xml                                   | Origin_att | Dest_att | Carrier_att |
2| ------ | ------------------------------------- | ---------- | -------- | ----------- |
3| 100.00 | 100.00                                | IND        | NYC      | ''          |
4| 200.00 | 200.00                                | IND        | LAX      | UAL         |
5| 500.00 | <perbagsurcharge>25</perbagsurcharge> | IND        | SEA      | ''          |

See Also