Walking through nokogiri and selecting elements with an xpath is fairly easy. I need the vice versa of this, meaning: I need to e.g. call .to_xpath
on a nokogiri node to get the full xpath of an element to store it in a record.
Anyone knows a way of doing this?
Easiest way I can think off would be:
Nokogiri::CSS.xpath_for node.css_path
EDIT: you can give path
method a try too.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With