From: Don Norcott Date: 2010-10-20T23:14:54+09:00 Subject: Re: Help missing something BASIC Thanks Robert I now have the code working with one additional line. require 'open-uri' require 'nokogiri' doc = Nokogiri::HTML(open("c:/RUBY_OUT.TXT")); doc.xpath("//table[@class='result']").each do |node| # next line has been added. doc2 = Nokogiri::HTML("" << "#{node}" << "") puts "*************" puts doc2.xpath("//td[@class='itemNumbr']") puts "*************" end I realized (even though I can not figure out why) early on that I had to save off each table in the "do" before processing it to get around this problem. I tried many things including an array which worked fine to save the s but I could not xpath the saved
s. What I did not realize that if I took the
raw it was no longer valid XML. What twigged me is your code adding in to give the correct html header Now if you can shed some light on my underlying question. Above I embed the node in a new html object, the new object contains nothing other than a single
. Also if print the node it contains only a single
. Yet if I attempt to execute "puts node.xpath("//td[@class='itemNumbr']")" it finds the "itemnumbr" for all
items even though they do not exist in node. Does node actually contain the entire html, just not visible. Thanks for any insight you can provide. Don -- Posted via http://www.ruby-forum.com/.