0
我试图用XML转换引入nokogiri到哈希:红宝石将引入nokogiri XML哈希
<eveapi version="2">
<currentTime>2016-05-01 11:38:14</currentTime>
<result>
<characterID>93898118</characterID>
<characterName>Ghitzarai</characterName>
<race>Minmatar</race>
<bloodlineID>4</bloodlineID>
<bloodline>Brutor</bloodline>
<ancestryID>24</ancestryID>
<ancestry>Slave Child</ancestry>
<corporationID>98012663</corporationID>
<corporation>Dry Atomic Fusion</corporation>
</result>
</eveapi>
# asume xml is the above XML
hash = {}
xml.xpath('//result').each do |row|
hash[get_node_name:] = row.content
end
现在row.name
将无法正常工作的原因,只有返回result
一次。
如何从子节点获取正确的名称?
我只是notised xml.xpath的lenght( '//结果')是onyl 1.所以也出现了问题是如何遍历孩子 –
使用'... xpath('// result/*')...'? – har07
啊,是的,工作。非常感谢! –