Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 16 additions & 17 deletions articles/logic-apps/expression-functions-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -4971,7 +4971,17 @@ And returns this result XML:

The `xml()` function expects either an object or a string containing valid XML. The function doesn't accept a raw array as input.

If your data is a JSON string, you can use the `json()` function to convert the string to a JSON object before you pass the result to the `xml()` function, for example:
If you have a JSON array, like the following example, you have four options.

```json
[
{ "ID": 1, "Name": "James" },
{ "ID": 2, "Name": "John" },
{ "ID": 3, "Name": "Sam" }
]
```

Option 1: Convert JSON string to a JSON object before you pass the result to the `xml()` function, for example:

```
xml(
Expand All @@ -4983,31 +4993,21 @@ xml(
)
```

If you have a JSON array, like the following example, you have three options.

```json
[
{ "ID": 1, "Name": "James" },
{ "ID": 2, "Name": "John" },
{ "ID": 3, "Name": "Sam" }
]
```

Option 1: Store the JSON array in a **Compose** action named **Compose1**. Then use the `outputs()` function to return a JSON object from **Compose1**.
Option 2: Store the JSON array in a **Compose** action named **Compose1**. Then use the `outputs()` function to return a JSON object from **Compose1**, and store the returned JSON object in another **Compose** action named **Compose2**.

```
{
"root": { "array": @{outputs('Compose1')} }
}
```

Store the returned JSON object in another action named **Compose2**. You can then use the `xml()` and `outputs()` functions to create XML from the JSON object output from **Compose2**, for example:
You can then use the `xml()` and `outputs()` functions to create XML from the JSON object output from **Compose2**, for example:

```
xml(outputs('Compose2'))
```

Option 2: Store the JSON array in a **Compose** action named **Compose1**. Then use the `outputs()`, `concat()`, `json()`, and `xml()` functions to create XML from the JSON object output, for example:
Option 3: Store the JSON array in a **Compose** action named **Compose1**. Then use the `outputs()`, `concat()`, `json()`, and `xml()` functions to create XML from the JSON object output, for example:

```
xml(
Expand All @@ -5019,10 +5019,9 @@ xml(
)
)
)

```

Option 3: Store the JSON array in a **Compose** action named **Compose1**. You can then use the `outputs()`, `json()`, `addProperty()`, and `xml()` functions to create XML from the JSON object output, for example:
Option 4: Similar to option 3, but uses `addProperty()` instead of the `concat()` function to create the JSON object before passing it to the `xml()` function, for example:

```
xml(
Expand All @@ -5038,7 +5037,7 @@ xml(
)
```

All examples, which include the JSON string data example and options 1 to 3, return the following XML result:
All examples, which include options 1 to 4, return the following XML result:

```xml
<root>
Expand Down