I have a very complicated PHP file which generates a lot of HTML, but I'm interested in extracting only some of it (within the <div id="content"> element) to another file. The thing is, that element is generated by the PHP.
Is it possible to use PHP's native getElementById function to get the content element from another PHP file? Or even from within itself?
For example, something like this, but actually working:
$doc = new DomDocument;
// We need to validate our document before referring to the id
$doc->validateOnParse = true;
$doc->Load('file.php');
echo "The contents are: ".$doc->getElementById('content')->textContent;
I realize this would mean the PHP will have to be executed to generate the HTML, which could be why the answer is simply No, this is not possible and I also realize this would mean a lot of additional run time. I'm not worried about those at the moment, just if this is possible.