代码之家  ›  专栏  ›  技术社区  ›  rtpHarry

此xpath查询将选择什么?

  •  0
  • rtpHarry  · 技术社区  · 16 年前

    我有下面的xpath查询,它似乎在工作,但我只是想确保它没有错误:

    //link[@type='application/rss+xml' or @type='application/atom+xml' and @rel='alternate']
    

    目的是从网页执行feed自动发现。

    我想要它做的是:

    all link tags with either (rss or atom) and rel alternate
    

    但我怀疑它所做的是

    all link tags with either (rss) or (atom and rel alternate)
    

    如果我犯了错误,有人能澄清是否是这种情况,并提供正确的查询吗?

    谢谢

    1 回复  |  直到 16 年前
        1
  •  1
  •   Devon_C_Miller    16 年前

    根据 spec , and 优先级高于 or . 因此,后者是正确的解释。您需要添加括号来将 @type 表达式在一起。