【问题标题】:cannot access value of attribute using xpath无法使用 xpath 访问属性值
【发布时间】:2014-06-26 06:05:14
【问题描述】:

我无法根据第一个属性获取第二个属性的值。 我尝试获取内容属性的值。即4,450 来自以下 XML:

<meta itemprop="price" content=" 4,450" />

尝试使用此 XPath://meta[@itemprop=\"price\"][@content] 但我得到的输出类似于输入 XML。

【问题讨论】:

  • 考虑接受提供的答案。谢谢。

标签: xpath attributes


【解决方案1】:

content 属性前需要一个斜杠:

//meta[@itemprop='price']/@content

【讨论】:

    【解决方案2】:

    用法不正确。

    使用以下代码

    //meta[@itemprop=\"price\"]/@content
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-06-13
      • 1970-01-01
      • 1970-01-01
      • 2021-10-26
      • 1970-01-01
      • 2012-12-07
      • 2015-02-10
      相关资源
      最近更新 更多