开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜