---
schema_version: "1"
id: ece70eeb66dfd1376d47da34c5ed226e49f0e0d5399fc0e86d2f456a45339809
title: BuildRowSetFromXml()
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/marketing-cloud/ampscript/references/content/mc-ampscript-reference-content-build-rowset-from-xml.md
canonical_url: https://developer.salesforce.com/docs/marketing/marketing-cloud-ampscript/references/mc-ampscript-content/mc-ampscript-reference-content-build-rowset-from-xml.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 0318edacdd4e71646740805e5d67a0e2afdaa5aa467b8c3e74dff090172e6bb6
products:
  - AMPscript for Marketing Cloud
  - Marketing Cloud
---
# 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

<table>
  <tr>
    <td>Marketing Cloud Engagement</td>
    <td>✅ Yes</td>
  </tr>
  <tr>
    <td>Marketing Cloud Next</td>
    <td>✅ Yes</td>
  </tr>
</table>

## Syntax

```
BuildRowSetFromXml(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.

```
%%[
Set @sourceXml = "<root>
  <Flight origin='IND' dest='NYC'>100.00</Flight>
  <Flight origin='IND' dest='LAX' carrier='UAL'>200.00</Flight>
  <Flight origin='IND' dest='SEA'>500
    <PerBagSurcharge>25</PerBagSurcharge>
  </Flight>
</root>"

BuildRowsetFromXml(@xml, '//Flight', 1)
]%%
```

The system returns this rowset:

```
| Value  | Xml                                   | Origin_att | Dest_att | Carrier_att |
| ------ | ------------------------------------- | ---------- | -------- | ----------- |
| 100.00 | 100.00                                | IND        | NYC      | ''          |
| 200.00 | 200.00                                | IND        | LAX      | UAL         |
| 500.00 | <perbagsurcharge>25</perbagsurcharge> | IND        | SEA      | ''          |
```

## See Also

- [XPath Recommendation](https://www.w3.org/TR/1999/REC-xpath-19991116/) on W3.org
