lundi 21 mars 2016

Parse the xml from remote link using happymapper gem

I am trying to parse the remote link which contains xml data to show it on my website. But the happy mapper gem returns empty array in response. I have the following code in my lib.

module XmlParser
 class BlogFeeds
  include HappyMapper

  element :title, String

  def self.fetch_feeds
    xml_response = HTTParty.get("http://ift.tt/1pWfnux").body
    feeds = BlogFeeds.parse(xml_response)
    feeds.each do |feed|
      puts feed.title
    end
  end
 end
end

Can anyone help in this regards.

Aucun commentaire:

Enregistrer un commentaire