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

Ключ

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

Get elements XPath Version 7 (Net)

Action group: XML

...

Description

Gets a collection containing the content of elements with the specified tag.

Action icon

Image Added

Settings of parameters

PropertyDescriptionTypeFilling exampleMandatory field
Parameters
XML contextXML-contextRobin.XMLXML contextYes
XPathPath to XML-element in DOM modelRobin.String
Yes
Results
ResultA collection with the content of XML elements at the specified pathRobin.Collection

Special conditions of use

If XPath does not explicitly define a tag, we get a collection of the contents of tags that satisfy the specified XPath.

If a tagged element has daughter elements, the their contents are glued into a single string.

Example of use 

Task

Get the collection of elements with tag AUTHOR from the XML file Text.xml 

Image Added

Solution

Use the "Load XML", "Get  elements XPath" actions.

Implementation

  1. Assemble a robot scheme with the actions:
    Image Added
  2. Set the "Load XML" action parameter.
    Image Added
  3. Set the "Get elements XPath" action parameters.
    Image Added


  4. Click "Start" in the top panel.

Result

The program robot completed successfully. The collection of the elements with tag AUTHOR was obtained.

Получить элементы по XPath /

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

Получает коллекцию, содержащую контент элементов с указанным тегом.

Image Removed

Настройки

...

Контекст

...

XML-контекст

...

XPATH запрос.

Путь до тега (включительно), который содержит получаемое значение

...

Результат

...

Возвращает коллекцию элементов по указанному пути.

...

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

Если XPath не определяет тэг однозначно, то мы получаем коллекцию из содержимого тэгов, удовлетворяющих указанному XPath.

Если элемент по тэгу имеет дочерние элементы, то содержимое этих дочерних элементов склеивается в одну строчку.

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

Задача: получить коллекцию элементов с тегом AUTOR из XML файла Text.xml 

Image Removed

Решение: воспользоваться действиями "Открыть", "Получить элементы по Xpath".

Реализация:

...

Результат:

Программный робот отработал успешно. Коллекция элементов для тега AUTHOR получена.