Skip to content

Commit ce67e84

Browse files
authored
Simplify XML( ) example 4
1 parent 5197fe2 commit ce67e84

1 file changed

Lines changed: 15 additions & 16 deletions

File tree

articles/logic-apps/expression-functions-reference.md

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4971,7 +4971,17 @@ And returns this result XML:
49714971

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

4974-
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:
4974+
If you have a JSON array, like the following example, you have four options.
4975+
4976+
```json
4977+
[
4978+
{ "ID": 1, "Name": "James" },
4979+
{ "ID": 2, "Name": "John" },
4980+
{ "ID": 3, "Name": "Sam" }
4981+
]
4982+
```
4983+
4984+
Option 1: Convert JSON string to a JSON object before you pass the result to the `xml()` function, for example:
49754985

49764986
```
49774987
xml(
@@ -4983,17 +4993,7 @@ xml(
49834993
)
49844994
```
49854995

4986-
If you have a JSON array, like the following example, you have three options.
4987-
4988-
```json
4989-
[
4990-
{ "ID": 1, "Name": "James" },
4991-
{ "ID": 2, "Name": "John" },
4992-
{ "ID": 3, "Name": "Sam" }
4993-
]
4994-
```
4995-
4996-
Option 1: Store the JSON array in a **Compose** action named **Compose1**. Then use the `outputs()` function to return a JSON object from **Compose1**.
4996+
Option 2: Store the JSON array in a **Compose** action named **Compose1**. Then use the `outputs()` function to return a JSON object from **Compose1**.
49974997

49984998
```
49994999
{
@@ -5007,7 +5007,7 @@ Store the returned JSON object in another action named **Compose2**. You can the
50075007
xml(outputs('Compose2'))
50085008
```
50095009

5010-
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:
5010+
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:
50115011

50125012
```
50135013
xml(
@@ -5019,10 +5019,9 @@ xml(
50195019
)
50205020
)
50215021
)
5022-
50235022
```
50245023

5025-
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:
5024+
Option 4: Similar to option 3, but uses `addProperty()` instead of concat() function to build the JSON object before passing the result to the xml() function, for example:
50265025

50275026
```
50285027
xml(
@@ -5038,7 +5037,7 @@ xml(
50385037
)
50395038
```
50405039

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

50435042
```xml
50445043
<root>

0 commit comments

Comments
 (0)