activities
latest
false
- 概述
- 加密
- 数据库
- Java
- Python
- 网页 API
开发者活动
上次更新日期 2026年4月21日
UiPath.WebAPI.Activities.ExecuteXPath
对给定的 XML 文档执行指定的 XPath 表达式。有关 XPath 语法的更多信息,请转到此处。
属性
输入
- “现有 XML”- 此为包含要处理的 XML 的“XDocument”变量。填写该字段后,“XML 字符串”字段将无法使用。该字段仅支持“XDocument”变量。
- “XML 字符串”- 此为包含要处理的 XML 的字符串或字符串变量。填写该字段后,“现有 XML”字段将无法使用。该字段仅支持字符串和字符串变量。
- “XPath 表达式”- 此为包含 XPath 表达式的字符串或字符串变量。该字段仅支持字符串和字符串变量。
其他
- “私有”- 选中后将不再以“Verbose”级别记录变量和参数的值。
常见
- “显示名称”- 活动的显示名称。
输出
- “结果”- 此为“对象”变量,包含给定 XML 的已检索节点或节点集。该字段仅支持“对象”变量。
“执行 XPath”活动使用示例
The Execute XPath activity is used for reading and extracting data from .xml files.
To exemplify how to use this activity, we have created an example that uses the Execute XPath activity for extracting the name of a person from a .xml file.
此自动化流程的构建方法如下:
- 打开 Studio ,创建一个新“流程”。
备注:
Make sure to place the
.xmlfile inside the project folder. For this example we used theXMLfiles.txt. - Drag a Sequence to the Workflow Designer.
-
创建以下变量:
变量名称 变量类型 默认值 XMLString字符串 Result对象
-
- Drag a Read Text File activity inside the sequence container.
- In the Properties panel, add the name
Read XML filein the DisplayName field. - Add the value
"XMLfiles.txt"in the FileName field. - Add the variable
XMLStringin the Content field.
- In the Properties panel, add the name
- 在“读取文本文件”活动之后添加“执行 XPath”活动。
- In the Properties panel, add the variable
XMLStringin the XMLString field. - Add the value
"string(/catalog/book/author/text()[1])"in the XPathExpression field. This expression extracts the text found in the author field from thexmlfile. - 在“结果”字段中添加
Result变量。
- In the Properties panel, add the variable
- 将“写入行”活动拖动到“执行 XPath”活动之后。
- 在“文本”字段中添加表达式
"Result: " + Result.ToString。
- 在“文本”字段中添加表达式
- Run the process. The robot extracts the name of the author from the
.xmlfile and displays it in the Output panel.