ravi181229 Posted July 2, 2008 Share Posted July 2, 2008 Hi there, I am importing ustream feed and my script displays following warning: Error type: Php Warning Message: SimpleXMLElement::__construct() [function.SimpleXMLElement---construct]: Entity: line 1: parser error : Start tag expected, '<' not found My Code: $link = 'http://ustream.tv/live.rss'; $rss_feed = file_get_contents($link); $ustream = new SimpleXMLElement($rss_feed); $casts = $ustream->channel->item; foreach ($casts as $cast) { echo "<br>Title:".$cast->title; echo "<br>Link:".$cast->link; echo "<br>Embed:".$cast->embed; } Need help. Thanks. Link to comment https://forums.phpfreaks.com/topic/112940-error-with-simplexmlelement/ Share on other sites More sharing options...
Tchelo Posted July 2, 2008 Share Posted July 2, 2008 If allow_url_fopen is set to false, then file_get_contents will return nothing. You could go by creating new SimpleXMLElement with the url as first parameter, and true as third. Not sure about second parameter, which is for libxml options. Read the following for further information: http://www.php.net/simplexml-element-construct Link to comment https://forums.phpfreaks.com/topic/112940-error-with-simplexmlelement/#findComment-580154 Share on other sites More sharing options...
ravi181229 Posted July 2, 2008 Author Share Posted July 2, 2008 Hi Tchelo, I have tried with the following code : $link = 'http://ustream.tv/live.rss'; $rss_feed = file_get_contents($link); $ustream = new SimpleXMLElement($rss_feed, NULL, TRUE); it displays following warning: Error type: Php Warning Message: SimpleXMLElement::__construct() [function.SimpleXMLElement---construct]: I/O warning : failed to load external entity "33bd4 If I echo $rss_feed, it shows proper content. problem is when it comes to SimpleXMLElement. Link to comment https://forums.phpfreaks.com/topic/112940-error-with-simplexmlelement/#findComment-580259 Share on other sites More sharing options...
Tchelo Posted July 2, 2008 Share Posted July 2, 2008 Well, if you are going to pass true to the third parameter, then the first should be the link, not its contents. Anyway, if you do get the correct contents, than there is something else wrong... I don't know how I can help right now, but I will try and research. Link to comment https://forums.phpfreaks.com/topic/112940-error-with-simplexmlelement/#findComment-580284 Share on other sites More sharing options...
ravi181229 Posted July 2, 2008 Author Share Posted July 2, 2008 Tchelo, I tried having first parameter as link also but it displays error. Its written in the reference link (php.net) that we can pass string data as well when third parameter is TRUE. I guess, you are right..there must be some other issue. But please post the solution if you find. Thanks a lot. Link to comment https://forums.phpfreaks.com/topic/112940-error-with-simplexmlelement/#findComment-580287 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.