Is this your html, or are you scraping someone else's html?
If it's yours, organize your html differently... if you know you want to
be processing a section at a time, wrap those sections with an
identifiable container, then scope your searches by the container.
(doc/"div").each do |dv|
this_h3 = (dv/"h3")
if this_h3.inner_html == "blah2"
(dv/"li").each do |li|
emits just c, and d
If its someone else's html in that format, you'll probably have to go
elem by elem for the whole doc with state machine-ish code to track what
you've seen previously since there doesn't seem to be any real 'path' to
the li's per h3.