We need to get the content inside DIV container with the ID of test in get_geo_location.php.
content.php
[sourcecode language="html"]
<html>
<head></head>
<body>
<div id="test"><p>I like blogging</p></div>
</body>
</html>
[/sourcecode]
Output should be : <p>I like blogging</p>
[sourcecode language="php"]
$content="content.php";
$source=new DOMdocument();
$source->loadHTMLFile($content);
$path=new DOMXpath($source);
$dom=$path->query("*/div[@id='test']");
if (!$dom==0) {
foreach ($dom as $dom2) {
$tmp_doc = new DOMDocument();
$tmp_doc->appendChild($tmp_doc->importNode($dom2,true));
$innerHTML .= $tmp_doc->saveHTML();
echo $innerHTML;
}
}
[/sourcecode]
No comments:
Post a Comment