Parsing WordPress RSS with PHP: I/O warning : failed to load external entity

I’m attempting to parse a wordpress RSS feed from PHP. The following works fine on my local server, but not with the host my site is actually on.

Read More

$url = "../blog/feed/"; $rss = simplexml_load_file($url);

foreach ($rss->channel->item as $item)
{
//Do stuff
}

However, on the server my site is hosted, I get the error “I/O warning : failed to load external entity”

Interestingly enough, though, whenever I manually save the RSS file as an xml file and point to that file, everything works fine. So while I could manually save and upload the xml file after every post I do, I’d rather automate it.

I really appreciate your time. I’ll probably talk to the host about it after this.

Related posts

Leave a Reply

1 comment

  1. I assume ../blog/feed/ is supposed to point to an URL (that probably gets rewritten by mod_rewrite).

    If you use a relative path inside the script, they are going to be treated as physical (filesystem) paths relative to where the script runs, not relative to the URL that is called in the browser.

    Specifying a full URL starting with http:// should help.