Vivek Netha wrote:

> could you give me more pointers on how exactly you would do it using 
> REXML. with actual code, if possible.

>>> x = Array.new
>>> x << doc.search("//li[@class='g w0']/h3/a")

Sure, but this is just tutorial-level REXML (hint hint), and uncompiled:

   require 'rexml/document'
   doc = REXML::Document.new(my_xml_string)
   x << REXML::XPath.first(doc, '//li[ @class = "g w0" ]/h3/a').text

Now we come to the very nub of the gist. A @class of "g w0" is the same as "w0 
g", or any other permutation, yet XPath is literal-minded, and unaware of CSS, 
so it will only match one of those permutations, when any other could have been 
just as significant.

You could try contains(@class, "w0"), but that would match "w0p0p", which is a 
different class.

This is why nokogiri is interesting - it might do CSS Selector notation, which 
is less exact than XPath, and more aware of CSS rules. (Look up assert_select() 
to see what I mean.)

For further REXML abuse, try this...

   http://www.google.com/codesearch?q=REXML%3A%3AXPath.first

...but be warned (again, I think), it's _almost_ as slow as Windows Vista with 
more than one program running, so /caveat emptor/.

-- 
   Phlip