tags:

views:

87

answers:

2

Is there a way of retrieving HTML (and JavaScript) contained in a div element?

A: 

Now about:

//div[@id='your div']

If you don't care about performance?

Piotr Czapla
A: 

I'm not a PHP developer but I found this:

function getNodeInnerHTML(DOMNode $oNode)
{
    $oDom = new DOMDocument();
    foreach($oNode->childNode as $oChild)
    {
        $oDom->appendChild($oDom->importNode($oChild, true));
    }
    return $oDom->saveHTML();
}

from http://www.sitepoint.com/forums/showthread.php?p=4225203

I don't think you can select content including with only XPath, so a function like the one above may be necessary. And then you select your div like //div[@id='someID'] etc.

lasseespeholt