Announcement (2017-05-07): www.ruby-forum.com is now read-only since I
unfortunately do not have the time to support and maintain the forum any
more. Please see rubyonrails.org/community and ruby-lang.org/en/community
for other Rails- und Ruby-related community platforms.

Hi,
I am new to ruby on rails.
I need to parse and read xml response from third party url using ruby on
rails.
For example if i make a request to url like
www.testurl234455.com/test/getsomething?param1=abcd
the url returns an xml response. for example the xml returned is
something:
<?xml version="1.0" ?>
<DATA>
<test>
<person>
<name>tester1</name>
<age>24</age>
</person>
</test>
</DATA>
I need read the name and age from the xml file after making request to
above url using ruby on rails.
Please help me. thanks in advance for your help

Bill Walton wrote:
> Kiran wrote:>>> I need to parse and read xml response from third party>> url using ruby on rails.>> REXML is part of the standard Rails distribution and is probably what> you're> looking for.>> hth,> Bill
Hi Bill,
Aware that REXML can be used but unable to find how it can be used to
parse resposes from urls. Search in google for that hasnt beenmuch help
ful
Small code sippet or name of the method used to do that can be helpful
Thanks
Kiran

>>>> Aware that REXML can be used but unable to find how it can be used to>> parse resposes from urls. Search in google for that hasnt beenmuch help>> ful>>>> Small code sippet or name of the method used to do that can be helpful
Here's a tutorial:
http://www.germane-software.com/software/rexml/doc...
Basically you can just create a Document by passing in the xml as a
string (response.body probably). Then you get the root element and pull
what you want out of the doc via xpaths.
Or, if you just need to convert all the content into a nested hash, see
below.
Gustav Paul wrote:
>> Cheers,> Gustav Paul>
That cobra thingy looks interesting... will have to check it out. But
you're right that rails will do this now (I think added as part of the
REST support in 1.2).
Rails adds a from_xml class method to Hash:
# ~/rails/whitelabel $ script/console
Loading development environment.
>> h = Hash.from_xml "<foo><bar>hello</bar><baz>there</baz></foo>"
=> {"foo"=>{"baz"=>"there", "bar"=>"hello"}}
>>
b