Jump to content

New At PHP....


rayj00

Recommended Posts

Firefox's XML error handling is traditionally worse than that of IE (yes, you read this right... IE beats Firefox in some cases, this being one of them).In their headers, they've specified
Content-type: text/xml;charset=ISO-8859-1

which is technically a correct thing to do (AFAIK), but they haven't done the same in their XML... the XML says

<?xml version="1.0" encoding="UTF-8" ?>

which is basically what's causing the problem... they need to choose an encoding and stick with it.

Ok, so I'll stick with Firefox for now.So when i query http://liberalforum.org/liberalforum/xml.php?showtopic it looks fine on the browser as well as the ->View->Page Source.So the php script is (test.php):
<?PHP$url = 'http://liberalforum.org/liberalforum/xml.php?showtopic';header('Content-Type: application/json');$xml = simplexml_load_file($url, 'SimpleXMLElement', LIBXML_NOCDATA);echo json_encode($xml);?>

When I browse the script (http://novir.us/test.php) with Firefox, the only thing I get back is the request to open or save test.php?There is nothing in the browser, and nothing in the View->Page Source!

Link to comment
Share on other sites

  • Replies 86
  • Created
  • Last Reply

I don't think you understood what I said earlier... Firefox is wrong! Firefox is misleading you! It says the XML is OK, but it is NOT. IE and PHP alike know that, and they don't try to be clever like Firefox - they do exactly what the spec expects them to do.And the XML is not OK because liberalforum.org have made an encoding error in its generation. Contact them! Tell them to either make their XML be UTF-8 encoded (and indicate so in the HTTP header by changing or omitting the charset parameter) or change the encoding accordingly to the HTTP header in the XML prolog.

Link to comment
Share on other sites

I don't think you understood what I said earlier... Firefox is wrong! Firefox is misleading you! It says the XML is OK, but it is NOT. IE and PHP alike know that, and they don't try to be clever like Firefox - they do exactly what the spec expects them to do.And the XML is not OK because liberalforum.org have made an encoding error in its generation. Contact them! Tell them to either make their XML be UTF-8 encoded (and indicate so in the HTTP header by changing or omitting the charset parameter) or change the encoding accordingly to the HTTP header in the XML prolog.
Ok so as it stands now, using IE, if you browse to: http://novir.us/test.php?url=http://libera...l.php?showforumit returns valid json. At least it validates at JSONlint.comHowever, if I browse to http://novir.us/test.php?url=http://libera...hp?showforum=44(notice the only difference in the URL is the "=44")I get Warning: simplexml_load_file() [function.simplexml-load-file]: http://liberalforum.org/liberalforum/xml.p...wforum=44:2072: parser error : Input is not proper UTF-8, indicate encoding ! Bytes: 0x92 0x54 0x20 0x46 in /hermes/bosweb/web172/b1723/sl.novirusa/public_html/test.php on line 5Warning: simplexml_load_file() [function.simplexml-load-file]: <title><![CDATA[Hawaii Governor Can’T Find Obama’S Birth Certificate]]></###### in /hermes/bosweb/web172/b1723/sl.novirusa/public_html/test.php on line 5Warning: simplexml_load_file() [function.simplexml-load-file]: ^ in /hermes/bosweb/web172/b1723/sl.novirusa/public_html/test.php on line 5falseAnd you are saying this is a problem with liberalforum.org I believe? How would they fix this?Thanks,Ray
Link to comment
Share on other sites

yes, that's what he's been trying to say. The character encoding defined in the headers and the character encoding of the XML don't match and this conflict is messing things up.

And the XML is not OK because liberalforum.org have made an encoding error in its generation. Contact them! Tell them to either make their XML be UTF-8 encoded (and indicate so in the HTTP header by changing or omitting the charset parameter) or change the encoding accordingly to the HTTP header in the XML prolog.
Link to comment
Share on other sites

yes, that's what he's been trying to say. The character encoding defined in the headers and the character encoding of the XML don't match and this conflict is messing things up.
I guess I am still somewhat confused. Why does one work and not the other?Ray
Link to comment
Share on other sites

It's a bug that they've caused... bugs happen for various reasons. Askings for bugs to be predictable is like wishing chaos was ordered... it's an oxymoron.In this case, I'm guessing it's someting messed up in a kind of logic that's limited within conditions matching the problematic page.

Link to comment
Share on other sites

I guess I am still somewhat confused. Why does one work and not the other?Ray
If you mean why it works for one browser and not the other, it's because one has "better" error handling versus the other. Browsers have all sorts of quirks that are specific to themselves, some do a better job of forgiving errors in markup and scripts than others.
Link to comment
Share on other sites

If you mean why it works for one browser and not the other, it's because one has "better" error handling versus the other. Browsers have all sorts of quirks that are specific to themselves, some do a better job of forgiving errors in markup and scripts than others.
No I'm wondering why one query returns valid json and the other don't?Here's a dumb question: When you purchase something like a forum software (IP Board), does the XML come with it?Thanks,Ray
Link to comment
Share on other sites

No I'm wondering why one query returns valid json and the other don't?Here's a dumb question: When you purchase something like a forum software (IP Board), does the XML come with it?Thanks,Ray
I'm not sure what your question means. I'm not too familiar with forum software, but typically they are database run, and the generated output is HTML, which is how we are viewing it currently. If a forum was to offer an API, they could choose how to offer the data to any given request; the two most popular being XML and JSON. The existence of these two formats is primarily meant to standardize the way information is given, and in turn, how the recipient can expect to get it and parse it.
Link to comment
Share on other sites

I'm not sure what your question means. I'm not too familiar with forum software, but typically they are database run, and the generated output is HTML, which is how we are viewing it currently. If a forum was to offer an API, they could choose how to offer the data to any given request; the two most popular being XML and JSON. The existence of these two formats is primarily meant to standardize the way information is given, and in turn, how the recipient can expect to get it and parse it.
I guess I wasn't clear. Who develops the XML or JSON code that is being used on the liberalforum or any othersite for that matter? I doubt that this particular site owner did it so that is why I asked if it comes with the software package?If I find a problem with XML or JSON being returned from the site, I need to know who is responsible, the site or the softwarevendor?Ray
Link to comment
Share on other sites

No I'm wondering why one query returns valid json and the other don't?
To paraphrase pastors, "bugs move in mysterious ways" :) .
Here's a dumb question: When you purchase something like a forum software (IP Board), does the XML come with it?
In the case of IP Board, version 2.3 and later, RSS support comes bundled in. This is not necesarily true for prior versions or any other software package.RSS however is one kind of XML. The XML that liberalforum.org outputs isn't RSS. It's another kind of an XML... one that I'm guessing they made up, and therefore support for it didn't come along with IPB.
Link to comment
Share on other sites

To paraphrase pastors, "bugs move in mysterious ways" :) .In the case of IP Board, version 2.3 and later, RSS support comes bundled in. This is not necesarily true for prior versions or any other software package.RSS however is one kind of XML. The XML that liberalforum.org outputs isn't RSS. It's another kind of an XML... one that I'm guessing they made up, and therefore support for it didn't come along with IPB.
Interesting as I really can't see the board owner taking the initiative to include XML.
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.


×
×
  • Create New...