From: Stuart Clarke Date: 2010-10-27T06:34:50+09:00 Subject: Re: REXML advice - output Could anybody help me with an issue you I am having with some XML I am reading. I am using xpath to read 2 different parts of an XML file, which looks a lot like this 84 0 BLAH LAH 12345 NEXT ITEM AS BOVE Then I have further data, which is slightly different 84 0 BLAH LAH 12345 As you can see, the tags are the same but the first is DoneList and the second NotDoneList. I need to process each set seperately and each set can contain more than 1 entry. My code to give a CSV file is doc = REXML::Document.new(d) #call REXML to open the XML file #To get NotDoneList data doc.elements.each("//NotDoneList/Vector/Count/FullItemInfo") do |e| detail = ( e.elements['ItemInfo/Title'].text << "," << e.elements['ItemInfo/Id'].text ) puts detail end #To get DoneList data doc.elements.each("//DoneList/Vector/Count/FullItemInfo") do |e| detail = ( e.elements['ItemInfo/Title'].text << "," << e.elements['ItemInfo/Id'].text ) puts detail end When I run this, no data in extracted and no errors are given. In contrast if I do doc.elements.each("//FullItemInfo") do |e| I am able to extract all the information for both the NotDoneList and DoneList, however this is not what I want. I want to address each data set separately. The eventual idea will be to produce a report of all items in the NotDoneList and another report for those in the DoneList. I guess I am doing something wrong but I cannot see it. Can anyone see what I am doing wrong with this? I would really appreciate any help as I cannot figure it out. Many thanks -- Posted via http://www.ruby-forum.com/.