views:

61

answers:

0

If the following code in Ruby can print out "browser type" and "count" individually as 2 separate lists, can REXML select each entry and then print out entry['title'].text and entry['dxp:metric'].attr('value') /* not using exact syntax */ on the same line as one list?

require 'rexml/document'
include REXML

xmlfile = File.new("data.xml")
xmldoc = Document.new(xmlfile)

xmldoc.elements.each("feed/entry/title"){ 
   |e| puts "Browser : " + e.text
}

xmldoc.elements.each("feed/entry/dxp:metric"){ 
   |e| puts "Count : " + e.attributes['value']
}