DOMDocument::loadHTML() error
by Ranganathan[ Edit ] 2012-12-06 00:00:29
<?php
// view_source('http://www.newsreporter.in/chanderpaul-returns-to-the-number-one-spot-78515');
$ch = curl_init("http://www.newsreporter.in/chanderpaul-returns-to-the-number-one-spot-78515");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
$content = curl_exec($ch);
//echo $content;
$doc = new DOMDocument();
$doc->loadHTML($content);
$elements = $doc->getElementsByTagName('div');
if (!is_null($elements)) {
foreach ($elements as $element)
{
$cl=$element->getAttribute("class");
if($cl=="content")
{
$nodes = $element->childNodes;
foreach ($nodes as $node) {
echo $node->nodeValue;
}
}
}
}
curl_close($ch);
?>
Guna
looks good if you could've explained, what is the issue and how it is solved...
0
0
Add Reply