From: Robert Klemme Date: 2011-02-28T21:20:33+09:00 Subject: Re: Nokogiri not pulling correct XPath On Mon, Feb 28, 2011 at 10:28 AM, Scott B. wrote: > I was wondering if anyone could help me. I'm trying to pull text from a > website using nokogiri and not all the text is not being pulled into my > variables through XPath. > > I have used Firebug (Firefox extension) to pull the correct XPath from > the page so I'm thinking it should be correct. So far, I have: > > variable1 = > (doc/"/html/body/div[2]/div[7]/div[4]/div[3]/div[6]/div/div/div/div/div/div/div/h2").inner_html > > variable 2 = > (doc/"/html/body/div[3]/div[7]/div[4]/div[3]/div[6]/div/div/div/div/div/div[2]/table/tbody/tr/td[2]/strong").inner_html > > variable 3 = > (doc/"/html/body/div[3]/div[7]/div[4]/div[3]/div[6]/div/div/div/div/div/div[2]/table/tbody/tr/td[2]/strong[2]").inner_html > > Now, variable1 is working but I can't get any values out of variable2 or > variable3. Is there a different syntax I should be using? To test, I've > only been outputting to the cli but I want to eventually push these into > a sqlite3 database. > > Anyone have any ideas? First I would dump the page _as loaded by your program_ (this is important) to disk and verify that those XPaths do work independently (e.g. with Firefox's DOM Inspector or Eclipse XML tools). Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/