Mark Thomas wrote:

> Who needs loops when you have XPath? You can grab an entire column in
> one fell swoop.
> 
>   require 'xml'
>   doc = XML::Parser.string(html).parse
>   column1 = doc.find('/table/tr[position()>1]/td[1]/text()')
>   puts column1.to_a
> 
> You'll need libxml for that (gem install libxml-ruby). Hpricot is not
> XPath compliant enough.
> 
> See my XPath article here:
> http://markthomas.org/2008/08/22/improve-your-XML-parsing-with-XPath/
> 
> -- Mark.


I looked over you XPath article.  Thanks.

But given the table structure noted above, will XPath actually work to 
take the variables that I need in each of the columns and insert those 
into database fields?  I need to locate 3 separate columns and grab each 
of those by row and insert those into a table.  So the html and the 
database table will end up looking the same.

Thanks.

-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to