What Ruby library can be used to select attribute using XPath, and to use it as the starting point for other XPath queries.
Example:
<root>
<add key="A" value="B" />
<add key="C" value="D" />
<add foo="E" bar="F" />
</root>
Desired code:
get_pair "//*/@key", "../@value"
get_pair "//*/@foo", "../@bar"
Expected output:
"A" "B"
"C" "D"
"E" "F"
Pseudo implementation:
def get_pair(key, value)
xml_doc.select[key].each do |a|
puts [a, a.select[value]]
end
end