I'm reading a rss feed and check I'm want to know how much time its taken to call
$homepage = file_get_contents('http://www.forbes.com/news/index.xml');
for this I'm using
<?php
$start = microtime(true);
$homepage = file_get_contents('http://www.fohgggrbes.com/news/index.xml');
$end = microtime(true);
$dur=$end-$start;
echo $dur;
$xml = simplexml_load_string($homepage,'SimpleXMLElement', LIBXML_NOCDATA);
echo '<pre>';
?>
but my requirement is first I check the file is valid xml ,if is it ,then its show response time
$homepage = file_get_contents('http://www.forbes.com/news/index.xml');
or if the XML file is not valid then shows error message. I want to use try and catch exceptions.