There is probably a very simple answer to this, but I want to be as detailed as possible so that you do not need me to clarify.
I am trying to collect the contents of every
<content><div>CONTENT</div></content>
The content needs to be returned as a backreference ($1). Both the content and the div have differing parameters (such as style="color: white;"). These parameters are unimportant, but exist nonetheless.
The complication is that the div may contain child div's. These are not important, but conflict with my current regex - stopping the match early.
Here is a sample of the code, imagine this copy/pasted several times and formatted differently.
<entry>
<title>A general title of a post</title>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
This is a description of the title. It may <b>contain bold text</b> or <div>even divs</div>, and everything else. It is not quite important to save these tags, but they exist nonetheless.
</div>
</content>
</entry>
Currently, I am using two regex codes. One for the declaration, and one for the closing tags. This works, but now I need to execute code on the contents. So, I will use preg_replace_callback(), but I can't figure out how to connect the two so that the middle is a callback.
Declaration:
<content \w+\s*=\s*\".*?\">[\r\n\s]{0,}<div \w+\s*=\s*\".*?\">
Closing:
</div>[\r\n\s]{0,}</content>
I need these combined, with the contents returned as a callback. I have tried something like ([\w\W]{0,}), which returns absolutely everything, but this match doesn't stop at the closing div.
So I found out about the \bFULLWORD\b command, and threw \bdiv\b on that... But I have had no success getting that to work. Perhaps it is not supported by PHP? Or I am stupid.
I do not know.
Please help!
DOMDocumentclass : fr2.php.net/domdocumentqp($html)->find("content div")->text();