I want to get all the links on a page so I could get attributes like title of the a href etc...
<?php
function exception_handler($exception) {
echo "Uncaught exception: " , $exception->getMessage(), "\n";
}
set_exception_handler('exception_handler');
function dom_create()
{
echo("domcreate");
$file = file_get_html('http://www.facebook.com/plugins/fan.php?connections=100&id=40796308305');
echo($file);
$doc = new DOMDocument();
$doc->loadHTMLFile($file);
$xpath = new DOMXpath($doc);
$elements = $xpath->query("//*[@id]");
if (!is_null($elements)) {
foreach($elements as $e){
$documentLinks = $e->getElementsByTagName('a');
}
else
echo "NULL";
}
}
dom_create();
?>
I don't get any output even if I just set echo statements. Anyone an idea?