From: Robert Klemme Date: 2010-09-17T00:13:21+09:00 Subject: Re: REXML advice - output On Thu, Sep 16, 2010 at 4:42 PM, Stuart Clarke wrote: > Hey all, > > I would like to pick your brains about Rexml and how to report from it. > For example, I am reading an XML file using references to each XML tag > like so: > > doc.root.each_element("/UserData/List/ItemInfo/Title") {|e| >  report.puts "Title: #{e.text}" > } > doc.root.each_element("/UserData/List/ItemInfo/Date") {|e| >  report.puts "Date: #{e.text}" > } > > The 'report.puts' writes this data out to a CSV file. At present I get a > list of all the titles in the XML file followed a list of the dates. > What I need it to get the side by side in a CSV file like so > > Title             Date > Item1             20th Jan 2009 > Item2             12th Feb 2010 > > Does anyone have any suggestions on a suitable workflow for this? Just iterate over all "ItemInfo" elements and print values from sub elements (which you can select via a relative XPath). Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/