php - simplexml_load_file() [function.simplexml-load-file]: Start tag expected, '<' not found in -


i using simplexml_load_file load bbc weather rss feed , randomly gives following error:

warning: simplexml_load_file() [function.simplexml-load-file]:  :1: parser error : start tag expected, '<' not found in 

it seems fail randomly. code not dynamically changing can't figure out why fails sometimes.

if grab rss file "supposedly" has missing < tag , store on computer , point simplexml_load_file location works fine.

any advice appreciated minor issue driving me mad.

try curl

<?php $k = 'http://open.live.bbc.co.uk/weather/feeds/en/2656173/3dayforecast.rss'; $ch = curl_init();     curl_setopt($ch, curlopt_url, $k);     curl_setopt($ch, curlopt_header, 0);     curl_setopt($ch, curlopt_returntransfer, 1);     $rss = curl_exec($ch);     curl_close($ch);      $xml = simplexml_load_string($rss, 'simplexmlelement', libxml_nocdata);     echo "<pre>";     print_r($xml);     echo "</pre>";      // if want items      //$xml->channel->item item array      //so       foreach($$xml->channel->item $item){     echo $item->title;  // can results here     } ?> 

Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -