PHP simplexml_load_file: File URL problem

Hi,

I'm trying to read an rss feed with simplexmlloadfile(). But on my Linode server (not with my local server) there is a problem with URL scheme.

If I try this as the source file: "http://www.domain.com/rss" it reads file just fine. But if I change URL to this: "http://www.domain.com/?feed=rss" it doesn't.

As I said there is no problem with both URLs on my development server. What could be the problem?

3 Replies

I'm not sure if http://www.domain.com/?feed=rss is technically a valid URL (even if it works). Try specifying the filename:

http://www.domain.com/whatever.php?feed=rss

@Guspaz:

I'm not sure if http://www.domain.com/?feed=rss is technically a valid URL (even if it works). Try specifying the filename:

http://www.domain.com/whatever.php?feed=rss

RFC 3986 says it's cool… //www.domain.com/ is the hier-part, and ?feed=rss is the query. If http://www.domain.com/ works, then http://www.domain.com/?feed=rss should work. Whether it does the right thing is an implementation question…

What does http://www.domain.com/?feed=rss do instead of working, and why does http://www.domain.com/rss (which is a completely different object, with hier-part //www.domain.com/rss) work?

Are you applying urlencode() to the URL by any means? That would screw up the question mark.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct