Вы можете получить доступ к результатам XPath, запросив элемент узла следующим образом.
require 'net/http'
require 'libxml'
# Sample text with a few tables
xml=<<END
<html>
<table id="t1"><tr><td>foo</td></tr></table>
<table id="t2"><tr><td>goo</td></tr></table>
<table id="t3"><tr><td>hoo</td></tr></table>
</html>
END
# Parse the text into tables
source = LibXML::XML::Parser.string(xml).parse
tables = source.find('//table')
# The XPath #each iterator does each XML node
tables.each {|node|
puts node["id"]
}
Если у вас более старая версия libxml:
- puts node["id"]
+ puts node.property("id")