Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!news.musoftware.de!wum.musoftware.de!news.karotte.org!uucp.gnuu.de!newsfeed.arcor.de!newsspool2.arcor-online.net!news.arcor.de.POSTED!not-for-mail Content-Type: text/plain; charset="UTF-8" Message-ID: <1621260.MulQa8nmlF@PointedEars.de> From: Thomas 'PointedEars' Lahn Reply-To: Thomas 'PointedEars' Lahn Organization: PointedEars Software (PES) Date: Sat, 22 Sep 2012 03:46:30 +0200 User-Agent: KNode/4.4.11 Content-Transfer-Encoding: 8Bit X-Face: %i>XG-yXR'\"2P/C_aO%~;2o~?g0pPKmbOw^=NT`tprDEf++D.m7"}HW6.#=U:?2GGctkL,f89@H46O$ASoW&?s}.k+&. Followup-To: comp.lang.javascript MIME-Version: 1.0 Lines: 76 NNTP-Posting-Date: 22 Sep 2012 03:46:32 CEST NNTP-Posting-Host: 18673542.newsspool3.arcor-online.net X-Trace: DXC=1U3^2Z`cY=6kUFX=Y?aLP;McF=Q^Z^V384Fo<]lROoR18kF I encounter a situation where the responseXML of a XMLHttpRequest contains > a CDATA element, like: > > > > This is used to load data in a table. It works always in FF and in Chrome. > But in IE8 the table is not always loaded. > It took me a while to find that the problem is related to the presence of > a diacritic (ASCII>128) in the CDATA text block. In such cases the > responseXML is returned by IE with firstChild=null. It might be helpful for further diagnosis that the referred document object implements the IXMLDOMDocument interface which provides an `xml' property for its XML serialization. [1] Generally, it is better to start with `….responseXML.documentElement' or an element node found with `….responseXML.getElementsByTagName("…")[…]', because the returned XML document may have a preamble (one or more of XML declarations, processing instructions, DOCTYPE declaration), which will create nodes in the document tree before the root element node. > My question is how to handle this. I presume that I need to specify the > encoding somewhere. Make sure that your XML data uses one of the character encodings that XML applications must support (UTF-8 and UTF-16), or declare the used character encoding. [2] Not doing that and having incompatible code sequences in the XML data leads to the XML document being empty. Generally, UTF-8 is the best choice for XML data because it can encode all Unicode characters without using character references (such as € for the Euro sign), is widely supported, and in most cases has the smallest footprint while having all these properties. This is not so much of an issue with characters with code point below U+0080 because in that range most encodings (probably all that encode Latin letters) are compatible. In particular, UTF-8 is compatible with Windows-1252 ("ISO-8859-1") below U+0080 (it has the same code sequences for the same characters there). (For example, PHP 5.3.x uses "ISO-8859-1" by default.) I have tested this in Internet Explorer 6.0.2800.1106 with a server-side PHP 5.3.x application generating an XML 1.0 document from user input in the same HTML document. The XHR object was created with new ActiveXObject("Microsoft.XMLHTTP") BTW, there are no characters with *ASCII* code beyond 127 (0x7F). US-ASCII is a 7-bit encoding (code points and sequences 0x00 to 0x7F). > The response is in answer to a request of the form > asyncRequestor.open("POST",d2w.appID,true); > asyncRequestor.setRequestHeader("Content-type","application/x-www- form-urlencoded"); > asyncRequestor.send(txt); If `asyncRequestor' would hold a reference to an object implementing the IXMLHTTPRequest, XMLHttpRequest or XMLHttpRequest2 interface, you would need to define an event listener for the `readystatechange' or `load' event. As there is no such definition in the posted code, one could assume that `asyncRequestor' is referring to a user-defined object, in which case one would be left with guessing what actually happens. Only in this case it is apparent that the method of submitting the HTTP request is not relevant. PointedEars ___________ [1] [2] -- Use any version of Microsoft Frontpage to create your site. (This won't prevent people from viewing your source, but no one will want to steal it.) -- from (404-comp.)