Ran into a problem returning an XML data with special characters encoded into it through an AJAX call. The problem was that special characters (i.e. ñ -> ñ) throws an error when being returned through XML and is in the process of being parsed by the browser.
XML does not support named entities by default, you have to declare it before hand. Only < > & " and ' are predefined.
1 2 3
<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp " "> ]> <xsl:stylesheet xmlns="http://www.w3.org/1999/XSL/Transform" version="1.0">
Got this from here…
Instead of using named entities in the XML (I think this also affects JSON, I could be wrong since I didn’t test this is JSON) like ñ, use character references to support special character encoding.
white space = =
ñ = ñ = ñ
they are all the same… #160 is referenced/mapped to ” ” and #241 is referenced/mapped to ñ
So when forming your XML before returning it through an AJAX call, form the special characters via character reference.
Hope this helps you out there having this problem.