I'm looking for a way to grab *all* XML of a DOM node (in PHP5).
Something like the following, only it doesn't work! Thanks.
/* I want everything (all XHTML) in <div id="hell=">... </div> */
$dom = new domdocument;
@$dom->loadHTMLFile(' http://www.example.com ');
$xpath = new domxpath($dom);
$xNodes = $xpath->query("//div[@id='hello']//p/*");
$sText = '';
foreach ($xNodes as $xNode)
{
$sText .= $xNode->firstChild->data . ' ';
}
$sText = strip_tags($sTe xt);
echo 'Result:' . $sText;
--
Google Blogoscoped
Something like the following, only it doesn't work! Thanks.
/* I want everything (all XHTML) in <div id="hell=">... </div> */
$dom = new domdocument;
@$dom->loadHTMLFile(' http://www.example.com ');
$xpath = new domxpath($dom);
$xNodes = $xpath->query("//div[@id='hello']//p/*");
$sText = '';
foreach ($xNodes as $xNode)
{
$sText .= $xNode->firstChild->data . ' ';
}
$sText = strip_tags($sTe xt);
echo 'Result:' . $sText;
--
Google Blogoscoped
Comment