May 3, 2011
How should I get a div's content like this using dom in php?
Question by David
The div is like this
<div style="width:90%;margin:0 auto;color:#Black;" id="content">
this is text, severaltags
</div>
how should i get the div’s content including the
tags using dom in php?
Answer by Starx
To get the values, you can try something like this
$doc = new DOMDocument();
$doc->loadHTMLFile('link-t0-html-file.php');
$xpath = new DOMXPath($doc);
$element = $xpath->query("//*[@id='content']")->item(0);
echo $element->nodeValue;