From: Phlip Date: 2009-03-16T16:32:38+09:00 Subject: Re: `&' interpreted as argument prefix Arun Kumar wrote: > Hi, > I'm new to rubi and at present i'm trying to write a sample code for > html extraction and store it in the database. The following is the code > for that : > > doc = Hpricot(open("http://www.google.com/")) The offending line is: ele.instance_variable_set("@#{k}", v) Apparently Google pages contain very complex HTML, to relieve strain on their servers. Then, Hpricot does not "sanitize" its input. That k variable might contain a &, which Ruby then warns about. instance_variable_set() creates an instance variable, like this: @foo = v where 'foo' was in k. But if k contains '&foo', you get this: @&foo = v You can't write that in raw Ruby, so instance_variable_set() is warning you that you should not write it in "meta-programming" Ruby either. But none of this is your fault: It's a bug in Hpricot, which Google's advanced HTML uncovered. The conclusion: Switch to Nokogiri. It has an Hpricot compatibility mode, but its internal engine is libxml, which is one of the industry's leading XML (and therefor HTML) implementations. -- Phlip