You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/logic-apps/expression-functions-reference.md
+15-16Lines changed: 15 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4971,7 +4971,17 @@ And returns this result XML:
4971
4971
4972
4972
The `xml()` function expects either an object or a string containing valid XML. The function doesn't accept a raw array as input.
4973
4973
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:
4975
4985
4976
4986
```
4977
4987
xml(
@@ -4983,17 +4993,7 @@ xml(
4983
4993
)
4984
4994
```
4985
4995
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**.
4997
4997
4998
4998
```
4999
4999
{
@@ -5007,7 +5007,7 @@ Store the returned JSON object in another action named **Compose2**. You can the
5007
5007
xml(outputs('Compose2'))
5008
5008
```
5009
5009
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:
5011
5011
5012
5012
```
5013
5013
xml(
@@ -5019,10 +5019,9 @@ xml(
5019
5019
)
5020
5020
)
5021
5021
)
5022
-
5023
5022
```
5024
5023
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:
5026
5025
5027
5026
```
5028
5027
xml(
@@ -5038,7 +5037,7 @@ xml(
5038
5037
)
5039
5038
```
5040
5039
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:
0 commit comments