Skip to content
Merged
Changes from 4 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
74 changes: 74 additions & 0 deletions articles/logic-apps/expression-functions-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -4967,6 +4967,80 @@ And returns this result XML:
<person>
```

*Example 4*

The xml() function expects either an object or a string containing valid XML. It does not accept a raw array as input.
If your data is a JSON string, you can wrap it with the json() function to convert it into an object before passing it to xml().

```
xml(
json('{"root":{"array":[
{ "ID": 1, "Name": "James" },
{ "ID": 2, "Name": "John" },
{ "ID": 3, "Name": "Sam" }
]}}')
)
```

Suppose you have the JSON array and store in Compose1 action.

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

Option 1: Using a JSON object in Compose2

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

and then create XML from the JSON object.

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

Option 2: Using concat()

```
xml(
json(
concat(
'{"root":{"array":',
outputs('Compose1'),
'}}'
)
)
)
```

Options 1 and 2, along with the JSON string data, return this result:

```xml
<root>
<array>
<ID>1</ID>
<Name>James</Name>
</array>
<array>
<ID>2</ID>
<Name>John</Name>
</array>
<array>
<ID>3</ID>
<Name>Sam</Name>
</array>
</root>
```

<a name="xpath"></a>

### xpath
Expand Down