Check element existence Version 1 (Net)
Action group: XML
Description
The action checks if the element exists in the specified XML-document. An XML-document element means a document in text format intended for storing structured data, for exchanging information between programs.
The action selects the priority way to identify the item (name or xpath), i.e. if the user selects "By name" then the name is checked, if the item is not found then the action tries to find the item by xpath.
If the user has chosen to prioritize xpath identification, the xpath check is performed first, if the item is not found, the name check is performed.
Action icon
Settings of parameters
Parameter | Description |
---|---|
XML-document context | Context of the open XML-document. You can open the XML-document with the "Load XML" action. |
Search method | Method according to which the XML-element will be found. There are two options available: By element name, By element's XPath. |
Element name | Specified when selecting value "By element name" in the "Search method" field. |
Element's XPath | Specified when selecting the value "By element's XPath" in the "Search method" field. It is possible to specify both the path to the element and the element itself in the field. More details in the section: Get win-element |
Output parameters
Result Boolean type - "true" if the element exists in the XML-document, or "false" if the element is not found.
Settings of parameters
Property | Description | Type | Filling example | Mandatory field |
Parameters | ||||
XML-document context | The XML document in which the existence of the element will be checked. | Robin.XML | XML context | Yes |
Search method | The parameter sets the element search method. | Robin.String | Yes | |
Element Name | The name of the element to be checked for existence. If search by name is selected in the «Search Method» field, this field must be filled in. If a different search method is selected, the value in this field will not be taken into account. | Robin.String | No | |
Element’s XPath | The path to the element that needs to be checked for existence. If XPath search is selected in the «Search Method» field, this field must be filled in. If a different search method is selected, the value in this field will not be taken into account. | Robin.String | No | |
Results | ||||
Result | The action will return «true» if the element is contained in the XML document, or «false» if the element is not found. | Robin.Boolean | true |
Special conditions of use
- In the action, select whether you want to search for the item by name or by XPath.
- If the item is not found by the selected search method, the action will return "false".
- IF the element is found, the action returns "true".
- If the search parameter (By Name or By XPath) is not filled in, and it is specified in the "Search Method" parameter, the robot will return an error.
Example of use
Task
Check the existence of a BOOK element in an XML document Text.xml
Solution
Use the "Load XML", "Check element existence" actions.
Implementation
- Assemble a robot scheme with the actions.
- Set the "Load XML" action parameter.
- Set the "Check element existence" action parameters.
- Click "Start" in the top panel.
Result
The program robot completed successfully. The element was found.