Why does this Nokogiri XPath have a null return?

后端 未结 1 1419
没有蜡笔的小新
没有蜡笔的小新 2020-12-21 15:35

I\'m XPath-ing through a web page with NOKOGIRI. I\'m familiar with XPath, but I cannot figure out why my XPath fails to pick up the specific row. See the ruby code.

1条回答
  •  囚心锁ツ
    2020-12-21 16:18

    The tag is an optional tag which is implicit if it is omitted. This means the tags are inserted automatically by the browser when not present. They are not in the source code in your example, so nokogiri doesn't know about them.

    Firebug uses the generated DOM, which does contains the tbody elements, so the statement does match inside a browser.

    Remove both the tbody selectors and you should be fine.

    0 讨论(0)
提交回复
热议问题