Ali Hassan Mirza Ali Hassan Mirza - 4 months ago 9
Ruby Question

third party api parsing, xml parsing, raw data parsing, ror parsing, ror nokoigiri, third party api parsing with nokogiri

I have an application in ruby on rails and have a raw format data file as a response from third party API. I want to parse that file in xml and get some element values as I am using nokogiri gem. So is there any way to parse that file?

here is detail of nokogiri

https://github.com/sparklemotion/nokogiri

Answer

As you already have installed Nokogiri, you need to pass the raw file to Nokogiri to get the parsed response:

  parsed = Nokogiri::XML(raw_data)
  parsed = parsed.css("your_element_name").text