how to access a xml thourgh Ruby on rails

Hi to everyone,

I am getting xml in the below format

123

FirstSecondThird

FirstSecondThird

FirstSecondThird

I have to store this xml in my table sample which contain the fields as

id,first,second,third,child1,child2 and child3,all are string fields except id field

and my record structure to be

id first second third child1 child2 child3

Have you tried Nokogiri? You can access elements through XPath and iterate over them easily:

require 'nokogiri'

xml_doc = Nokogiri::XML(@string_with_your_xml) grn_elements = xml_doc.xpath('//grn') arn_elements = xml_doc.xpath('//arn') arn_elements[0].children each do |child|   puts "Name: #{child.name} Value: #{child.inner_text}" end

Thank you

But it is trowing the error as

NoMethodError: undefined method `each' for #<Nokogiri::XML::Element: 0x45146a0>

when i try with each

is there any way to access the arn_elements[0].children ?