From: Mark Thomas Date: 2009-11-10T11:35:05+09:00 Subject: Re: Using Nokogiri On Nov 9, 12:37 am, 7stud -- wrote: > Mark Thomas wrote: > > This should get what you want: > > > prefix = '//div[@class="sectionHeaderText"]/following-sibling::' > > xpaths = { > >  :name => "#{prefix}b/text()", > >  :addr => "#{prefix}text()[2]", > >  :citystzip => "#{prefix}text()[3]", > >  :country => "#{prefix}text()[4]", > >  :phone => "#{prefix}text()[5]", > > }   > > xpaths.each do |data,xpath| > >   puts "#{data} = " + doc.search(xpath).to_s.strip > > end > > > -- Mark. > > I was wondering if you could answer some xpath questions? I would think > that in this xpath: > > div[@class="sectionHeaderText"]/following-sibling::text()[2] > > the part: > > div[@class="sectionHeaderText"]/following-sibling > > would be the tag. Not quite. following-sibling:: is an axis predicate that needs to be followed by a node. Therefore following-sibling::text() is a set of all text nodes after the div. After that, it's just a matter of indexing. > doesn't seem applicable.  And in fact, when I run your code, it doesn't > work: As I just posted in another message, it works for me. I wonder what's different about my environment. Are you using Nokogiri 1.4.0?