XML: Parse string field
Use this action to save a value from a XML formatted string.
This action will save a single value, so it is best used for simple strings where only one item is needed. To save more than one value, use the XML: Convert XML to JSON action then convert the JSON using the Field: Create fields from JSON action.
Use case
This action is typically part of a process that involves Web API actions. A common application for this action is to convert the output of the Web API: Send Get Request action to JSON to use in a field formula or converted into a PagerDuty Workflow Automation field with the Field: Create fields from JSON action.
How to configure this action
Here’s an example of XML string as an input for this action:
<?xml version="1.0" encoding="UTF-8" ?><account><accountID>12345</accountID><accountName>Vandelay Industries</accountName><employees><employeeID>1</employeeID><name>Art Vandelay</name></employees><employees><employeeID>2</employeeID><name>Kel Varnsen</name></employees><employees><employeeID>3</employeeID><name>H.E. Pennypacker</name></employees></account>
The following examples demonstrate the effects of different XPath Expressions when evaluated over the XML string above.
XPath Expression | XPath Effect | Result |
---|---|---|
//name | Returns the first name node, no matter where it is |
Art Vandelay |
//employeeID | Returns the first employeeID node, no matter where it is |
1 |
account//accountName | Returns the accountName that is the child of account |
Vandelay Industries |
/account/employees/name[2] | Returns the second name node |
Kel Varnsen |
/account/* | Returns the first child node of the account node |
12345 |
//name[last()] | Returns the last name node, no matter where it is |
H.E. Pennypacker |
All expressions will return the first value, even if it were to return multiple results. In some cases, a fix task may occur when an XPath expression returns multiple results.
Fields for this action
-
XML String to Parse From
- Enter the XML text or field reference to XML text to parse from.
-
XPath Expression
- Enter the XPath Expression to evaluate over the XML file.
-
Filename You Want to Save the Result As
- Enter a name for the field in which the result should be saved.
- The step’s name is used as the output field name by default.
What will this output?
The name of the output field where the value is stored will be the Filename You Want to Save the Result As defined during configuration.
Output fields for this action
Thanks for your feedback
We update the Help Center daily, so expect changes soon.
Link Copied
Paste this URL anywhere to link straight to the section.