1

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.


$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.

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

3 Comments

I would use the http://, but there is a server configuration that I do not have the authority to change preventing that. "URL file-access is disabled in the server configuration". So I'm guessing it needs to be relative in some way. The strange thing is if I manually put an xml file in the same directory and use that, it works. So ../blog/rss.xml works. But I'd rather not have to update manually.
@Joseph then you'd have to find the correct file path to use. As said, /blog/feed is a virtual URL, it doesn't exist on filesystem level. It might be worth a separate question to find that out
@Joseph also check out whether this answer helps to go a different route stackoverflow.com/questions/2055725/pull-data-from-wordpress/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.