Strange xpath output

/home/pt/jiexi content is:

require ‘rubygems’
require ‘nokogiri’
doc = Nokogiri::HTML.parse(open(’/home/pt/jiexi’))
table=doc.xpath(’//ul[@id=“ul_list”]/li/a’)
puts table
output
irb(main):005:0> puts table




=> nil
puts table.xpath(’//ul’)
irb(main):006:0> puts table.xpath(’//ul’)

what i think is the script “puts table.xpath(’//ul’)” will not create
any output.
how strange it is to get the result,would you mind to tell me why?

On Mon, Jul 05, 2010 at 11:00:38AM +0900, Pen T. wrote:

title="ok3">
  • what i think is the script “puts table.xpath(’//ul’)” will not create
    any output.
    how strange it is to get the result,would you mind to tell me why?

    “//ul” says “find all ul tags anywhere in the document”. It looks like
    you have a ul tag in your document, and the XPath is doing what it is
    supposed to do.

    Why would you expect “//ul” to have no results?

    On 05.07.2010 04:00, Pen T. wrote:

    title="ok3">
  • what i think is the script “puts table.xpath(‘//ul’)” will not create
    any output.
    how strange it is to get the result,would you mind to tell me why?

    That’s perfectly expected. If you look closely at the eplanation,
    you’ll find out:

    http://www.w3schools.com/Xpath/xpath_syntax.asp

    You probably wanted

    puts table.xpath(‘ul’)

    Kind regards

    robert