我正在使用Nokogiri1.3.3和Ruby1.8.7,我正在尝试匹配标签的内容,如 this SO question :
nodeset.xpath("entry/index[. = '#{index.to_s}']/../categories")
Nokogiri提出了一个例外,抱怨 . “在括号后面。当我更换' . 用 text() 然后它抱怨第二阶段。这是我还是Nokogiri?我该怎么修
.
text()
如果我正确理解您的文档结构,您应该能够:
nodeset.xpath("entry[index='#{index.to_s}']/categories")
对我来说更容易理解。