Using Nokogiri, I would like to determine the name of the root element.
I thought that running an XPath query for / would do the trick, but apparently the node name is a "document"?
require 'nokogiri' doc = Nokogiri::XML('<foo>Hello</foo>') doc.xpath('/').first.name
How can I get the string "foo" for the root root name without knowing it ahead of time?
source share