[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: Hpricot and xpath

Li Chen

8/13/2008 1:45:00 AM

Subject: Re: Hpricot and xpath=0A=0A> tag1.rb:6: undefined method `xpath' f=
or nil:NilClass (NoMethodError)=0A>Do you see the nil in that line? Where i=
s the nil coming from? Is the method =0A>before the .xpath, on line 6, poss=
ibly returning a nil and not an Elem?=0A=0A>After pondering that, switch '#=
header' to '.header'!=0AHi Phlip,=0AThank you for your dot!!!=0AI follow yo=
ur suggestion and change to=A0'.header'=A0 or ".header"=A0instead of "#head=
er" and and it works. Ruby returns the tag's path=A0like this:=A0 /tag1/tag=
2/div. But I see nowhere in the document about=A0=A0using "." and "#" in xp=
ath() or css_path(). Do I miss something in the docucment?=0ALi=0A=0A=0A =


1 Answer

Phlip

8/13/2008 3:44:00 AM

0

chen li wrote:

> I follow your suggestion and change to '.header' or ".header" instead of "#header" and and it works. Ruby returns the tag's path like this: /tag1/tag2/div. But I see nowhere in the document about using "." and "#" in xpath() or css_path(). Do I miss something in the docucment?

That's just the thing. I studied the crap out of HTML, XHTML, and light CSS, and
never learned until encountering assert_select that CSS has its own query
notation. Others with different career paths have learned nothing but - and they
all assume you know the same things.

Hpricot can handle _light_ XPath, and can handle various CSS Selector notations.
The documenters have all assumed that someone else taught you how they work. So
google for "CSS Selector", without x-ref'ing Hpricot!

--
Phlip