I can’t figure out how get only those ‘div’-s (with content) which don’t contain other div(s).
For example:
<div id='first'>
...
<div id='second'>
...
</div>
</div>
<div id='third'>
...
</div>
And I need only the ‘second’ and ‘third’ divs’ content, opening and closing tags because they don’t include other divs.
I tried this pattern: ~(<div id='[a-z].+')(.*?)(</div>)~s
But it’s not ok.
I hope I’am clear… thank you in advance!!
While I’m not a Nazi about using rexex to extract HTML, this problem is a lot easier with xpath and the DOM.
I didn’t test that code. But the key part is the not operator that finds all divs without a div childnode.