I wanted to work on something like the following example string
require ‘hpricot’
string = ‘posted on
April
2009’
h = Hpricot(string)
t = “2009-04-06”
Here it goes: confusion No.1
h.at(‘a[@title*=“2009-04-06”]’)
##=> returns the 2nd anchor element, as expected.
h.at(‘a[@title*=Time.now.strftime(“%Y-%m-%d”)]’)
##=> 1st anchor element. Why is that??
h.at(“a[@title*=#{t}]”)
##=> 2nd anchor. works fine
h.at(‘a[@title*=“#{t}”]’)
##=> nil. Because of the single quote?
And here comes another confusion:
year = “2009”
h.at(“a[@title*=#{t}][text()=‘2009’]")
##=> 2nd anchor, as expected.
h.at("a[@title=#{t}][text()*=#{year}]”)
##=> nil. Why is that? Hpricot can’t handle #{} more than once?
Hope you can fill me in on this one. Thanks!!
##Jay