Just to be perfectly clear. If the structure is like this
**subhead**
subrow
p
p
p
**subhead**
subrow
p
p
subrow
p
subrow
p
**subhead**
subrow
p
subrow
p
the desired output is [3,4,2]? Indentations means “child of”.
Maybe
function countp(body::HTMLNode)
i = 0
counts = Int[]
for e in body.children
if e isa HTMLElement{:div} && get(e.attributes, "class", "")=="ttt-subhead"
push!(counts, 0)
i += 1
end
counts[i] += length(eachmatch(Selector("div.ttt-row > p"), e))
end
counts
end