From: Mark Thomas Date: 2009-11-10T11:20:05+09:00 Subject: Re: Using Nokogiri > 7stud's approach works, but Mark's doesn't (currently). Strange... it works for me. mark@ubuntu:~$ ruby -v ruby 1.8.7 (2009-06-12 patchlevel 174) [i486-linux] Nokogiri 1.4.0 libxslt 1.1.24-2ubuntu2 Here's the entire working program: require 'rubygems' require 'nokogiri' html =<

Association Detail

DETAIL DIRECTORY RESULTS
Some Institute name

some address
city, st zip
United States
Phone: (123) 456-7890

) Web address: www.xyz.org


Back to Search Results

Search Again ENDOFHTML doc = Nokogiri::HTML.parse(html) 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 |k,xpath| puts "#{k} = " + doc.search(xpath).to_s.strip end # Output: addr = some address citystzip = city, st zip country = United States phone = Phone: (123) 456-7890 name = Some Institute name