Data scrap using DOMXPath,Data scrap xpath->query

By | July 4, 2014

Html Data format

$html = file_get_contents(‘http:something.com’);
$mydoubts_doc = new DOMDocument();
libxml_use_internal_errors(TRUE);
if(!empty($html)){
$mydoubts_doc->loadHTML($html);
libxml_clear_errors();
$mydoubts_xpath = new DOMXPath($mydoubts_doc);
$fulldata=array();
$mydoubts_row = $mydoubts_xpath->query(‘//div[@class=”col-sm-3″]/a’);
if($mydoubts_row->length > 0){
foreach($mydoubts_row as $row){
$fulldata[]=$row->nodeValue;
}
}

}

print_r($fulldata);

Array ( [0] => Vasanthan [1] => abandon [2] => Vasanthanpv)