to manipulate the DOM of the current page using PHP?
I would like to know how to manipulate the DOM of the current page using PHP. The explanation is as below:
This is the code in my PHP file:
<div id="edittitle" title="Editing title"> <b>1</b> </div> $strhtml=; libxml_use_internal_errors( true ); $dom=new DOMDocument('1.0','utf-8'); $dom->validateOnParse=false; $dom->loadHTML( $strhtml ); libxml_clear_errors(); $col=$dom->getElementsByTagName('b'); echo $col->item(0)->nodeValue;
Actually, what I want is putting the whole html code that exists in the current file (the PHP file) in the variable $strhtml (Please focus on the following line of my code: $strhtml=;). Is there any idea about how to do that?
Thanks in advance.
If you really want to you can do this by putting all of your HTML in an output buffer while / before sending it to the browser (the latter can be easily done with output control). Then you can DOM parse the "captured" HTML.