I am trying to access some particular children in a document. I find
myself having to loop (several levels) through children checking name ==
“xxx”. I am wondering whething there is more direct way of getting the
same. Here’s a simple sample.
I am trying to get the href of a class called prevnext (on browser it is
doc = Nokogiri::HTML(open(‘http://www.reddit.com/r/programming/’))
nextlink = nil
doc.css(‘p.nextprev’).each do |link|
link.children.each do |child|
if child.name == “a”
nextlink = child.attributes[“href”].value
Can i not access a.href more directly in the doc.css line itself ?