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
精彩评论