From: Robert Klemme Date: 2010-09-07T15:30:09+09:00 Subject: Re: how to write this xpath? On 07.09.2010 07:07, Pen Ttt wrote: > there is an html file > > > > >
ok > Sep 10 > |Oct 10 > |Dec 10 > > > > > >
> 123 > > 567 >
>
> when i open it with firefox,the output is : > ok Sep 10 | Oct 10 | Dec 10 > 123 567 > what i want to get is > ok Sep 10 | Oct 10 | Dec 10 > here is my codes > require 'rubygems' > require 'nokogiri' > web='/home/test' > doc = Nokogiri::HTML.parse(open(web)) > data=doc.xpath('/html/body/table/tr/td') > puts data > i get > ok > Sep 10 > |Oct 10 > |Dec 10 > > > >
> 123 > > 567 >
> > how can i get : > ok > Sep 10 > |Oct 10 > |Dec 10 You want the first row? Try '/html/body/table/tr[1]/td' See also http://www.zvon.org/xxl/XPathTutorial/General/examples.html http://www.w3schools.com/xpath/ Cheers robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/