From: Robert Klemme Date: 2008-03-31T06:53:07+09:00 Subject: Re: rexml to slow On 30.03.2008 22:21, Bu Mihai wrote: > Robert Klemme wrote: >> On 30.03.2008 20:23, Bu Mihai wrote: >>> 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. > > I'm not sure if that will works, i have a xml file with this > structure(and it must be like this, the following example is a simple > sample of the original): > > > > page1 > page2 > page3 > > page4 > > ....and so on > > > > > > > > > I have a recursive function to find all 'page' nodes with attribute > 'again' 'yes but i need to start the searc from the beging of the file > or from the current node and the display all subnodes with 'yes'; You can use the XPath from the root and I believe also from a particulara node. > after > the all nodes was founded then i need to search them again from the > begining of the file; When I asked what your program does, I really meant: Can you explain in non technical words what this program is supposed to do? Since you seem to traverse over the same nodes over and over again I have the strong feeling that there is a better alternative - but for that we need to know the purpose of the program. > Many thanks for your help Robert. You're welcome. Kind regards robert