On Aug 12, 2:03 ¨Âí¬ Ìé Ãèåî ¼ãèåîß®®®Àùáèïï®ãïí¾ ÷òïôåº > 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? Look carefully. It's not defined for nil. Which means that doc.at("header") is returning nil. That's because there are no elements with the name of "header"; only an attribute. Try using the css selector "#header".