开发者

Fastest/One-liner way to print XML node's XPath in Ruby?

开发者 https://www.devze.com 2022-12-13 05:43 出处:网络
What\'s the fastest/on开发者_JAVA百科e-liner way to print the current nodes xpath, or just \"path/to/node\", in Ruby with Nokogiri?

What's the fastest/on开发者_JAVA百科e-liner way to print the current nodes xpath, or just "path/to/node", in Ruby with Nokogiri?

So this:


<nodeA>
    <nodeB>
        <nodeC/>
    </nodeB>
</nodeA>

to this (say we've gone down to nodeC by processing xml.children.each, etc...):

"nodeA/nodeB/nodeC"


node.path

You can find the full documentation of node here: http://nokogiri.rubyforge.org/nokogiri/Nokogiri/XML/Node.html

0

精彩评论

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