代码之家  ›  专栏  ›  技术社区  ›  John F. Miller

nokogiri xpath表达式未分析

  •  0
  • John F. Miller  · 技术社区  · 15 年前

    我正在使用Nokogiri1.3.3和Ruby1.8.7,我正在尝试匹配标签的内容,如 this SO question :

    nodeset.xpath("entry/index[. = '#{index.to_s}']/../categories")
    

    Nokogiri提出了一个例外,抱怨 . “在括号后面。当我更换' . text() 然后它抱怨第二阶段。这是我还是Nokogiri?我该怎么修

    1 回复  |  直到 15 年前
        1
  •  1
  •   Greg Campbell    15 年前

    如果我正确理解您的文档结构,您应该能够:

    nodeset.xpath("entry[index='#{index.to_s}']/categories")
    

    对我来说更容易理解。