Parsing XML feed into Ruby object using nokogiri?
Posted
by Galen King
on Stack Overflow
See other posts from Stack Overflow
or by Galen King
Published on 2010-05-20T22:13:28Z
Indexed on
2010/06/03
2:14 UTC
Read the original article
Hit count: 440
Hi all,
I am pretty green with coding in Ruby but am trying to pull an XML feed into a Ruby object as follows (ignore the ugly code please):
<% doc = Nokogiri::XML(open("http://api.workflowmax.com/job.api/current?apiKey=#{@feed.service.api_key}&accountKey=#{@feed.service.account_key}")) %>
<% doc.xpath('//Jobs/Job').each do |node| %>
<h2><%= node['name'].text %></h2>
<p><%= node['description'].text %></p>
<% end %>
Basically I want to iterate through each Job and output the name, description etc.
What am I missing?
Many thanks,
Galen
© Stack Overflow or respective owner