From: Robert Klemme Date: 2008-03-31T03:50:15+09:00 Subject: Re: rexml to slow On 30.03.2008 20:23, Bu Mihai wrote: > Robert Klemme wrote: >> On 29.03.2008 08:46, Bu Mihai wrote: >>> I have an xml file and sometimes i call the find_first_recursive method; >>> when my xml file is small its working fine but when i have ~900 lines im >>> waiting ~15 seconds to return me the wanted node and i want something >>> faster; How can i obtain a better time? >> What's the find criteria you use? Maybe you can use XPath. 900 lines >> does not really sound large so I suspect there might be an algorithmic >> or design error. > > this is the criteria: > > node=rexml_element.find_first_recursive {|node| > node.attributes["again"]=="yes"} That's easy doc.elements.each('//[@again="yes"]') do |node| # any node that has attribute again with value yes end And I am pretty sure that this is faster than your approach. What does your program do? With more context we can come up with further suggestions. Kind regards robert