UiPath Documentation
activities
latest
false

开发者活动

上次更新日期 2026年4月21日

执行 XPath

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.

此自动化流程的构建方法如下:

  1. 打开 Studio ,创建一个新“流程”
    备注:

    Make sure to place the .xml file inside the project folder. For this example we used the XMLfiles.txt.

  2. Drag a Sequence to the Workflow Designer.
    • 创建以下变量:

      变量名称变量类型默认值
      XMLString字符串
      Result对象
  3. Drag a Read Text File activity inside the sequence container.
    • In the Properties panel, add the name Read XML file in the DisplayName field.
    • Add the value "XMLfiles.txt" in the FileName field.
    • Add the variable XMLString in the Content field.
  4. “读取文本文件”活动之后添加“执行 XPath”活动。
    • In the Properties panel, add the variable XMLString in 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 the xml file.
    • 在“结果”字段中添加 Result 变量。
  5. “写入行”活动拖动到“执行 XPath”活动之后。
    • 在“文本”字段中添加表达式 "Result: " + Result.ToString
  6. Run the process. The robot extracts the name of the author from the .xml file and displays it in the Output panel.
  • 属性
  • “执行 XPath”活动使用示例

此页面有帮助吗?

连接

需要帮助? 支持

想要了解详细内容? UiPath Academy

有问题? UiPath 论坛

保持更新