How do I load the contents of an rss feed rendered by php?
-
Wordpress is rendering an RSS feed at http://myurl.com/feed/rss/ but of course there's not actually a file there. I'm writing a script to read and render the RSS, but loading the "file" as XML fails, because there's not actually a file there. I write: $rss = simplexml_load_file('/news/feed/rss/'); And I get this error: Warning: simplexml_load_file() [function.simplexml-load-file]: I/O warning : failed to load external entity "/news/feed/rss/" Even using file_get_contents gives me this error: Warning: file_get_contents(/news/feed/rss/) [function.file-get-contents]: failed to open stream: No such file or directory
-
Answer:
The file isn't there because the url is being redirected, but you're trying to access it as a file. Assuming you have the correct fopen wrappers (and everyone does), try opening the url with simplexml: $rss = simplexml_load_file('http://myurl.com/news/feed/rss/');
Corey at Stack Overflow Visit the source
Other answers
The best way is to use Curl ( http://us2.php.net/manual/en/book.curl.php ) for loading external content because you can manipulate with headers etc., it also supports redirects etc. For example, if mod_security is installed on apache - you wouldn't be able to grab content without passing user-agent header etc., but Curl will definately will help with it.
Kirzilla
Related Q & A:
- How Can I Load Balance Two Wireless Routers?Best solution by Super User
- How do I add an RSS Feed to My Yahoo?Best solution by Yahoo! Answers
- How do I load my webcam on yahoo?Best solution by ehow.com
- How do I remove recorded contents from my DVD+R disc?Best solution by Yahoo! Answers
- How can I load my avatar so that it can show up?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.