#134 √ resolved
Justin Jones

Hash.from_xml wrong?

Reported by Justin Jones | February 18th, 2008 @ 08:16 AM | in 0.9.4

Hash.from_xml seems to be wrong, at least from being Rails/ActiveResource compliant.

eg.

{ 
  :zoo => {
    :name => 'Los Angeles Zoo',
    :animals => [
      { :name => 'Lion' },
      { :name => 'Tiger' }
    ]
  }
}.to_xml

# Should return something along the lines of:
#
# <zoo>
#   <name>Los Angeles Zoo</name>
#   <animals>
#     <animal>
#       <name>Lion</name>
#     </animal>
#     <animal>
#       <name>Tiger</name>
#     </animal>
#   </animals>
# </zoo>

# Hash.from_xml() on the same string gives:
=> {"zoo"=>{"name"=>"Los Angeles Zoo", "animals"=>{"animal"=>[{"name"=>"Lion"}, {"name"=>"Tiger"}]}}}
# It should be "animals"=>[The array] instead of "animals"["animal"]=>[The array]

# Also, nil case is not handled correctly
Hash.from_xml('<name type="integer"></name>')
=> {"name"=>{"type"=>"integer"}} # Should be {"name"=>nil}

Comments and changes to this ticket

Please Login or create a free account to add a new comment.

You can update this ticket by sending an email to from your email client. (help)

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Shared Ticket Bins

Tags