When parsing XML like this:
<clients>
<client>
<id>23</id>
<addresses>
<address>
<street>gogostreet</street>
</address>
</addresses>
</client>
</clients>
An exception is raised: ArgumentError: expected an attributes Hash, got "gogostreet"
I fixed the problem by editing the function from_xml_data(data) in connection.rb
I changed it to:
# Manipulate from_xml Hash, because xml_simple is not exactly what we
# want for ActiveResource.
def from_xml_data(data)
case data
when Hash
if data.keys.size == 1
case data.values.first
when Hash then [ from_xml_data(data.values.first) ]
when Array then data[data.keys.first] = from_xml_data(data.values.first)
else data
end
else
data.each_key { |key| data[key] = from_xml_data(data[key]) }
data
end
when Array then data.collect { |val| from_xml_data(val) }
else data
end
end
Just changing the data.values.first to data seems to solve this problem, though it was there for a reason probably. Haven't tested it properly to. Take a look.