View Full Version : AJAX: How Can I Ask XML Parser Stop Complaining?

08-18-2005, 02:02 AM
I am writing AJAX code to retrieve XML from server using PHP. It works most of the time. But once in a while, I encounter XML Parsing Error: not well-formed Error. Inside the XML returned from the server, there may be code that are not qualified as XHTML because it's older stuff, maybe that's why the parser is complaining and I don't plan to change these older stuff. As a result, I can't retrieve any xml from it. I don't really care about the not well-formed error because I am need only bits and pieces inside the xml and I don't care about the form.

Is there a way to force the parser to return the Not well-formed XML, so that I can read what's inside the XML returned?

Many thanks.

08-18-2005, 03:16 AM
I found the solution, just want to share with you guys.

if you use php in server, use urlencode() to encode the html or whatever code that may potentially upset XML parser. Then in javascript, use decodeURIComponent to decode the stuff in xml back to html or whatever.

08-18-2005, 12:28 PM
the other way is to use CDATA (http://www.w3schools.com/xml/xml_cdata.asp) sections which tell the XML parser to ignore everything within it.