I’m parsing an XML document and trying to create an array of hashes
using the following:
roomcats = Array.new
rmcategory = Hash.new
doc.xpath(’//RoomCategory’).each do |rc|
However what I’m getting is an array of hashes with all elements of the
array equal to the last element. A bit of experimenting has shown that
each time the hash value changes through the loop the associated entry
in the Array is also changed. i.e. The array element is ‘pointing’ to
the hash rather than taking on separate values.
Please can someone tell me what I should do to achieve what I want.