Сравнение версий

Ключ

  • Эта строка добавлена.
  • Эта строка удалена.
  • Изменено форматирование.

...

Check element existence Version 1 (Net)

Группа действийAction group: XML 

Описание

Действие проверяет существование элемента в указанном XML-документе. Под элементом XML-документа подразумевается документ в текстовом формате, предназначенным для хранения структурированных данных, для обмена информацией между программами.

Действие выбирает приоритетный способ идентификации элемента (имя или xpath), т.е. если пользователь выбрал значение "По имени", то происходит проверка по имени, если элемент не нашелся, то действие пробует найти элемент по xpath.

Если пользователь выбрал приоритетный способ идентификации по xpath, то сперва происходит проверка по xpath, если элемент не нашелся, то выполняется проверка по имени.

Иконка

Image Removed

Параметры

Входные параметры

Контекст XML-документа          Контекст открытого XML-документа. Открыть XML-документ можно с помощью с действия "Открыть" (группа "XML"). 

Способ поиска                           Способ по которому будет найден XML-элемент. Доступны 2 варианта: по имени XML-элемента, по XPath XML-элемента. 

Имя XML-элемента                    Заполняется при выборе значения "по имени XML-элемента" в поле "Способ поиска". 

XPath XML-элемента                  Заполняется при выборе значения "по XPath XML-элемента" в поле "Способ поиска". В поле возможно указать, как путь к элементу, так и сам элемент. Подробнее в разделе: Eng_Получение win-элемента

Выходные параметры

Результат Логический тип -  «true», если элемент содержится в XML-документе, или «false», если элемент не найден.

Настройки

...

Свойство

...

Описание

...

Тип

...

Пример заполнения

...

Обязательность заполнения поля

...

Параметры

...

Контекст XML-документа

...

XML-документ, в котором будет проверяться существование элемента.

...

Robin.XML

...

Контекст XML

...

Да

...

Способ поиска

...

Параметр устанавливает способ поиска элемента.

...

Robin.String

...

Да

...

Имя элемента

...

Имя элемента, который необходимо проверить на существование. Если в поле «Способ поиска» выбран поиск по имени, это поле обязательно должно быть заполнено. Если выбран другой способ поиска, значение в этом поле не будет учитываться.

...

Robin.String

...

Нет

...

XPath элемента

...

Путь к элементу, который необходимо проверить на существование. Если в поле «Способ поиска» выбран поиск по XPath, это поле обязательно должно быть заполнено. Если выбран другой способ поиска, значение в этом поле не будет учитываться.

...

Robin.String

...

Нет

...

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

Image Added

Settings of parameters

ParameterDescription
XML-document contextContext of the open XML-document. You can open the XML-document with the "Load XML" action.
Search methodMethod according to which the XML-element will be found. There are two options available: By element name, By element's XPath. 
Element nameSpecified when selecting value "By element name" in the "Search method" field.
Element's XPathSpecified 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

PropertyDescriptionTypeFilling exampleMandatory field
Parameters
XML-document contextThe XML document in which the existence of the element will be checked.Robin.XMLXML contextYes
Search methodThe parameter sets the element search method.Robin.String
Yes
Element NameThe 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 XPathThe 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
ResultThe action will return «true» if the element is contained in the XML document, or «false» if the element is not found.Robin.Booleantrue

Special conditions of use

  1. In the action, select whether you want to search for the item by name or by XPath.
  2. If the item is not found by the selected search method, the action will return "false".
  3. IF the element is found, the action returns "true".
  4. 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

Image Added

Solution

Use the "Load XML", "Check element existence" actions.

Implementation

  1. Assemble a robot scheme with the actions.
    Image Added

  2. Set the "Load XML" action parameter.
    Image Added

  3. Set the "Check element existence" action parameters.
    Image Added
  4. Click "Start" in the top panel.

Result

The program robot completed successfully. The element was found.

Image Added

...

Результат

...

Действие вернет «true», если элемент содержится в XML-документе, или «false», если элемент не найден.

...

Robin.Boolean

...

true

Особые условия использования 

  1. В действии необходимо выбрать способ поиска элемента - по имени или по XPath.
  2. Если элемент не найден по выбранному способу поиска- действие вернет "false".
  3. Если элемент найден, действие возвращает "true".
  4. Если не заполнен параметр поиска (По имени или По XPath), а он указан в параметре  "Способ поиска", то робот вернет ошибку.

Пример использования 

Задача

Проверить существование элемента BOOK в XML-документе Text.xml

Image Removed

Решение

Воспользоваться действиями "Открыть", "Проверить существование элемента". 

Реализация

...

Результат

Программный робот отработал успешно. Элемент найден. 

Image Removed