开发者

XPATH selecting node with attribute and text

Given (no comments about the XML naming necessary):

<config>
  <unit>
    <var name='model'>3100</var>
    <var name='type'>production</var>
  </unit>
<unit>
    <var name='model'>0100</var>
    <var name='type'>test</var>
  </unit>
</config>

How can I construct an XPATH to select the node with the attribute "model" and the text 3100 using Ruby Nokogiri

I'm trying:

//var[@name='model' and text()='3100']

but getting "invalid predicate". Obviously that's just the XPATH with the Nokogiri calls omitted. I don't seem to be having an开发者_如何转开发y problems with the Nokogiri usage, so my request is just about fixing the XPATH.


That works with nokogiri 1.5, Are you using a very old version?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜