XPath using PHP

$html = file_get_contents($url);
$dom = new DOMDocument();
$dom->loadHTML($html);
$xpath = new DOMXpath($dom);
$nodes[‘key’] = $xpath->query(‘//div/h2[@id=key]/a’);
$nodes[‘src’] = $xpath->query(‘//div/h2[@id=key]/a/text()’);

foreach($nodes as $key => $value){
for($i=0;$ilength;$i++){
$data[$key] = $value->item($i)->nodeValue;
}
}

print_r($data);