From: daz Date: 2005-09-04T10:41:26+09:00 Subject: Re: How to get REXML to return items in order?? Gavin Kistner wrote: > On Sep 3, 2005, at 3:16 PM, ted wrote: > > I'm new to Ruby and can't figure out why REXML isn't returning the > > elements > > in the order they appear in the document. Here's my code and the > > document. > > I confirm the problem. Looks like a bug. [...] .... and it's fixed in CVS for 1.8.3 If you need this now, you could download the later version here: http://www.ruby-lang.org/cgi-bin/cvsweb.cgi/ruby/lib/rexml/rexml.tar.gz?only_with_tag=ruby_1_8;tarball=1 to e.g. "C:\Ruby\TEMP" then change the lookup path at the top of your script. $:.unshift('C:/Ruby/TEMP') # for rexml fixes require 'rexml/document' xml = REXML::Document.new(DATA) xml.elements.each("//span[@class='c5']") do |element| puts element end #-> 1st Title #-> 2nd Title #-> 3rd Title __END__
1st Title
2nd Title
3rd Title
daz