Get XML Data
Gets data from an XML, which can be accessed by a URL or entered as a Text.
Command availability: IBM RPA SaaS and IBM RPA on premises
Script syntax
IBM RPA's proprietary script language has a syntax similar to other programming languages. The script syntax defines the command's syntax in the script file. You can work with this syntax in IBM RPA Studio's Script mode.
getXmlData --mode(GetXmlMode) --data(String) [--xpath(String)] (String)=value
Input parameter
The following table displays the list of input parameters available in this command. In the table, you can see the parameter name when working in IBM RPA Studio's Script mode and its Designer mode equivalent label.
Designer mode label | Script mode name | Required | Accepted variable types | Description |
---|---|---|---|---|
Read from | mode |
Required |
GetXmlMode |
Select how to get the XML data See the mode parameter options. |
XML or URL | data |
Required |
Text |
Field that receives the XML text or the URL in which the XML is located. |
XPath | xpath |
Optional |
Text |
XPath of the wanted data to get from the XML. |
mode
parameter options
The following table displays the options available for the mode
input parameter. The table shows the options available when working in Script mode and the equivalent label in the Designer mode.
Designer mode label | Script mode name | Description |
---|---|---|
URL | Url |
URL where the XML data is obtained. |
XML | Xml |
XML where the data is obtained. |
Output parameter
Designer mode label | Script mode name | Accepted variable types | Description |
---|---|---|---|
Data | value |
Text |
Return data that is found on the given XML. |
Example
The XML is entered as a text, and its data are obtained and stored in a variable.
defVar --name data --type String
getXmlData --mode "Xml" --data "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<notepad>\r\n <note>\r\n <to>Sales Manager</to>\r\n <from>Employee</from>\r\n <heading>Reminder</heading>\r\n <body>Don't forget our meeting at 9:00 AM!</body>\r\n </note>\r\n</notepad>" --xpath "/notepad" data=value
logMessage --message "Obtained data: ${data}" --type "Info"