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
-

Michael Murray February 19th, 2008 @ 10:50 PM
Yeh I noticed this too, I added some failing specs from your examples.
-
Yehuda Katz (wycats) February 28th, 2008 @ 04:47 PM
- → Assigned user changed from to Michael D. Ivey (ivey)
- → State changed from new to open
- → Milestone changed from to 0.9
Who wrote from_xml? It looks rather complex.
-
Michael D. Ivey (ivey) February 28th, 2008 @ 11:28 PM
I went back to my 0.5.x checkout and did svn blame. sethrasmussen at gmail wrote that code.
I'll work on this one if no one else does it.
-
Michael D. Ivey (ivey) February 28th, 2008 @ 11:32 PM
- → Assigned user cleared.
hassox says he wrote it originally.
-

Daniel Neighman (hassox) February 29th, 2008 @ 12:10 AM
from_xml was changed to use a Stream parse instead of Hpricot for speed reasons.
The original ticket is here
-

Justin Jones February 29th, 2008 @ 03:48 AM
There is this: http://www.movesonrails.com/arti...
It's a from_xml made for ActiveResource using libxml ruby gem, supposedly very quick.
Just depends if we want an extra dependency, I suppose.
-
-
Yehuda Katz (wycats) March 3rd, 2008 @ 06:58 PM
- → Assigned user changed from to Daniel Neighman (hassox)
-
Yehuda Katz (wycats) March 4th, 2008 @ 03:25 PM
- → Milestone changed from 0.9 to 0.9.4
-

Daniel Neighman (hassox) March 6th, 2008 @ 08:08 AM
- → State changed from open to resolved
This has been closed by http://github.com/wycats/merb-co...
Specs have been taken from ActiveSupport to ensure compatibility with ActiveResource.
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 »
