Skip to content

Commit 71b9c47

Browse files
authored
Merge pull request #127845 from watana2/main
Minor update: Refine XML( ) example 4
2 parents 145e6b4 + 868651e commit 71b9c47

1 file changed

Lines changed: 16 additions & 17 deletions

File tree

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

Lines changed: 16 additions & 17 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 the JSON string to a JSON object before you pass the result to the `xml()` function, for example:
49754985

49764986
```
49774987
xml(
@@ -4983,31 +4993,21 @@ 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**, and store the returned JSON object in another **Compose** action named **Compose2**.
49974997

49984998
```
49994999
{
50005000
"root": { "array": @{outputs('Compose1')} }
50015001
}
50025002
```
50035003

5004-
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:
5004+
You can then use the `xml()` and `outputs()` functions to create XML from the JSON object output from **Compose2**, for example:
50055005

50065006
```
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 the `concat()` function to create the JSON object before passing it 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 the examples from options 1 to 4 return the following XML result:
50425041

50435042
```xml
50445043
<root>

0 commit comments

Comments
 (0)