【问题标题】:Get Attribute value from another attribute value in xml file in robot framework从机器人框架的xml文件中的另一个属性值获取属性值
【发布时间】:2021-01-02 09:08:05
【问题描述】:

以下数据为xml文件。 这里actual,msg,time,type是属性。


<properties>    
    <inputs>
        <action actual="0xAB" msg="GENERAL.GROUPING.TAG" time="00:00:00.825" type="SET" />
        <action actual="0xCD" msg="GENERAL.GROUPING.LENGTH" time="00:00:00.826" type="SET" />
        <action actual="0xEF" msg="GENERAL.GROUPING.TRANSACTION_ID" time="00:00:00.826" type="SET" />
        <action actual="0xGH" msg="GENERAL.GROUPING.ORIGINATOR_SYSTEM_TITLE" time="00:00:00.827" type="SET" />
        <action actual="0xIJ" msg="GENERAL.GROUPING.VALUE" time="00:00:00.827" type="SET" />
        <action actual="0xKL" msg="GENERAL.GROUPING.TITLE.LENGTH" time="00:00:00.827" type="SET" />
        <action actual="0xMN" msg="GENERAL.GROUPING.TITLE.VALUE" time="00:00:00.828" type="SET" />
        <action actual="0xOP" msg="GENERAL.GROUPING.DATE" time="00:00:00.828" type="SET" />
    </inputs>
</properties>  

当属性msg="GENERAL.GROUPING.TAG" 时,我想返回actual="0xAB" 的属性值。 所以根据属性'msg'值我想打印属性'实际'值 请通过示例帮助解决此问题。

【问题讨论】:

  • 到目前为止您尝试了什么,您可以将其添加到问题中吗?

标签: xml xpath robotframework


【解决方案1】:

您可以使用这个 XPath-1.0 表达式:

//action[@msg='GENERAL.GROUPING.TAG']/@actual

返回属性值0xAB

【讨论】:

  • @priyas 而不是谢谢你可以通过点击答案旁边的空心勾号来接受答案
  • 我点击了空心刻度
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-08-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多