【问题标题】:On UiPath how can I extract (from an XML File) the second tag if there are multiple tags with the same name?在 UiPath 上,如果有多个同名标签,我如何(从 XML 文件中)提取第二个标签?
【发布时间】:2021-09-21 10:31:41
【问题描述】:

我有一个具有以下特征的 XML 文件:

   <Root>
    <Example>
     <Address> Sesame Street </Address>
     <Address> New York US </Address>
    </Example>
    <Example>
     <Address> Nairobi KE</Address>
    </Example>
   </Root>

我想总是提取第二个标签(美国纽约)或第一个标签,如果它只有一个标签。但是在 UiPath 上,当我尝试提取(使用 Execute XPath 活动)时,它总是返回第一个。 关于如何提取第二个或第一个(如果它是唯一一个)的任何建议?

【问题讨论】:

    标签: xpath uipath uipath-studio


    【解决方案1】:

    我的理解是你总是想要一个示例中的last地址元素,这可以通过在谓词中使用XPath函数last()来实现。

    //Address[last()]

    这会同时选择“New York US”和“Nairobi KE”元素。

    我对这个问题有点不清楚,但如果您的意图是只提取“纽约美国”,您可以指定您只想要第一个示例中的最后一个地址。

    //Example[1]/Address[last()]

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-01-17
      • 2013-06-01
      • 1970-01-01
      • 1970-01-01
      • 2022-10-31
      • 1970-01-01
      • 1970-01-01
      • 2021-09-28
      相关资源
      最近更新 更多