require 'nokogiri'
require 'open-uri'
# Get a Nokogiri::HTML::Document for the page we’re interested in...
@doc = Nokogiri::XML(File.open("data.xml"))
# Search for nodes by css
ids = []
@doc.xpath('//itemid').each do |link|
ids << link.content
end
hash = {}
i = 0
@doc.xpath('//realestate').each do |link|
hash.store(link.to_s)
i+=1
#p hash
#sleep 2
#break if i ==1
end
p hash
一切正常。,除了hash.store。,我想要的是“用hash_id将数据存储在散列中。谢谢