Hi, I have a function that accepts a general HTML file and a general XPath expression. I want to extract a string of the matched node containing the entire text including HTML tags. Here's a simplified example...
<?php
$inDocStg = "
<html><body>
<div>The best-laid<br> schemes o' <span>mice</span> an' men
<img src='./mouse.gif'><br>
</div>
</body></html>
";
$xPathDom = new DOMDocument();
@$xPathDom->loadHTML( $inDocStg );
$xPath = new DOMXPath( $xPathDom );
$matches = $xPath->query( "//div" );
echo $matches->item(0)->nodeValue;
?>
This produces (I'm looking at the generated HTML source - not the browser output)...
The best-laid schemes o' mice an' men
(the HTML tags have been stripped out).
But what I want is...
The best-laid<br> schemes o' <span>mice</span> an' men<img src='./mouse.gif'><br>
Thanks.