From: Sandy Thomson Date: 2009-03-18T04:00:02+09:00 Subject: Re: XML to CSV with REXML - I'm sure this should be easy... matt neuburg wrote: > Sandy Thomson wrote: > >> ..but, whilst it works for one event with multiple dates, as soon as I >> add a second event it iterates through all of the dates against every >> event, so for 2 events each with 2 dates it outputs 8 lines... > > Cool! :) > >> xml.elements.each("//event") do |e| >> e.elements.each("//performance") do |p| > > Yeah, sorry about that. I wasn't thinking about the XPath here. > Obviously "//performance" is wrong. I shoulda said > "descendant::performance" or "performances/performance" or similar. > > Of course one could also argue that Ruby and REXML are more heavyweight > than you need; you're just dumpster-diving in simple XML and outputting > text, so you could write this whole thing as an XSLT template. Choices, > choices...! > > m. Choices indeed, but it works perfectly now so I'll go with it :) Thanks! -- Posted via http://www.ruby-forum.com/.