L
Li Chen
Hi all,
I want to find the path to a tag I am interested using hpricot.
According to the document and examples I think I should use #xpath
method.
I expect that ruby will return the path as this:
"/tag1/tag2/div[@id='header']"
but I get the following info:
tag1.rb:4: undefined method `xpath' for nil:NilClass (NoMethodError)
I wonder why method #xpath is not defined?
Thanks,
Li
###########################################
Here is my code:
require 'hpricot'
doc=Hpricot(open('tag.txt'))
puts doc
puts doc.at("header").xpath()
########tag.txt##########
<tag1>
<tag2>
<div id='header'>
</tag2>
</tag1>
I want to find the path to a tag I am interested using hpricot.
According to the document and examples I think I should use #xpath
method.
I expect that ruby will return the path as this:
"/tag1/tag2/div[@id='header']"
but I get the following info:
tag1.rb:4: undefined method `xpath' for nil:NilClass (NoMethodError)
I wonder why method #xpath is not defined?
Thanks,
Li
###########################################
Here is my code:
require 'hpricot'
doc=Hpricot(open('tag.txt'))
puts doc
puts doc.at("header").xpath()
########tag.txt##########
<tag1>
<tag2>
<div id='header'>
</tag2>
</tag1>