I am trying to use Nokogiri to parse an HTML file with some eccentric markup. In particular, I am trying to capture divs that have both identifiers and several classes and styles. The markup looks something like this:
<div id="foo"> <div id="bar" class="baz bang" style="display: block;"> <h2>title</h2> <dl> List of stuff </dl> </div> </div>
I am trying to capture the <dl> that is inside the div problem. I can get divs with a single id attribute without problems, but I cannot figure out how to get Nokogiri to grab divs with identifiers and classes. So they work great:
content = @doc.xpath("//div[id='foo']") content = @doc.css('div#foo')
But this does not return anything:
content = @doc.xpath("//div[id='bar']") content = @doc.xpath("div#bar")
Is there something obvious I'm missing here?
ruby xpath nokogiri
Timd
source share