Go to Google Groups Home    NWRUG
Re: [NWRUG] parse an xml snippet to a hash

Will Jessop <w...@willj.net>

On 2 Jul 2009, at 11:23, doug livesey wrote:

> Hi -- I have a custom ActiveResource action that returns the  
> following xml:

> "<result>\n  <successes>\n    <1>a082000000HqJzUAAV</1>\n    
> <2>a082000000HqJzsAAF</2>\n    <3>a082000000HqJzVAAV</3>\n  </
> successes>\n  <failures>\n  </failures>\n</result>\n"

> Is there a quick & easy way to turn this into the following hash?

> { "result" { "successes" => { "1" => "a082000000HqJzUAAV", "2" =>  
> "a082000000HqJzsAAF", "3" => "a082000000HqJzVAAV" }, "failures" =>  
> {} }

This might help:

http://xml-mapping.rubyforge.org/

Not used it myself though.

Will.

--
Will Jessop
Super Shiny Robot Limited - Professional web design and development

t: 07939 547 962
w: http://supershinyrobot.com/