[Home] [By Thread] [By Date] [Recent Entries]
Mark, Chars 0-31 [#x0-#x1F] (except 9 [#x9], 10 [#xA], and 13 #xD]) are illegal in XML. [2] Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF] /* any Unicode character, excluding the surrogate blocks, FFFE, and FFFF. */ See http://www.w3.org/TR/REC-xml.html#charsets Mike -----Original Message----- From: Mark Tucker [mailto:MTucker@i...] Sent: Thursday, March 21, 2002 2:54 PM To: xml-dev@l... Subject: MSXML DOM Special Chars Less Than 32 We are having trouble encoding special characters less than 32 (excluding 9, 10, and 13). One server is creating an XML DOM and returning the XML as a string. The calling server is then getting this XML string and loading it into a DOM. The following VB test app shows that assigning a special character to the Text property doesn't encode it in a way that a later call to loadXML will work: Dim xmldoc As MSXML2.DOMDocument Dim xmldoc2 As MSXML2.DOMDocument Dim strXML As String For x = 1 To 255 Set xmldoc = New MSXML2.DOMDocument Set pi = xmldoc.createProcessingInstruction("xml", " version='1.0'") xmldoc.appendChild pi Set e = xmldoc.createElement("test") e.Text = "chr(" & x & ")=" & Chr(x) & ";" xmldoc.appendChild e strXML = CStr(xmldoc.xml) Set xmldoc2 = New MSXML2.DOMDocument xmldoc2.loadXML strXML If xmldoc2.parseError.errorCode <> 0 Then Debug.Print x, "parseError:" & xmldoc2.parseError.reason End If Set xmldoc = Nothing Set xmldoc2 = Nothing Next The output is: 1 parseError:An invalid character was found in text content. 2 parseError:An invalid character was found in text content. 3 parseError:An invalid character was found in text content. 4 parseError:An invalid character was found in text content. 5 parseError:An invalid character was found in text content. 6 parseError:An invalid character was found in text content. 7 parseError:An invalid character was found in text content. 8 parseError:An invalid character was found in text content. 11 parseError:An invalid character was found in text content. 12 parseError:An invalid character was found in text content. 14 parseError:An invalid character was found in text content. 15 parseError:An invalid character was found in text content. 16 parseError:An invalid character was found in text content. 17 parseError:An invalid character was found in text content. 18 parseError:An invalid character was found in text content. 19 parseError:An invalid character was found in text content. 20 parseError:An invalid character was found in text content. 21 parseError:An invalid character was found in text content. 22 parseError:An invalid character was found in text content. 23 parseError:An invalid character was found in text content. 24 parseError:An invalid character was found in text content. 25 parseError:An invalid character was found in text content. 26 parseError:An invalid character was found in text content. 27 parseError:An invalid character was found in text content. 28 parseError:An invalid character was found in text content. 29 parseError:An invalid character was found in text content. 30 parseError:An invalid character was found in text content. 31 parseError:An invalid character was found in text content. I tried playing with the encoding on the initial DOM document, but it has no effect. How do I properly encode these special characters? Mark Tucker mtucker@i... ----------------------------------------------------------------- The xml-dev list is sponsored by XML.org <http://www.xml.org>, an initiative of OASIS <http://www.oasis-open.org> The list archives are at http://lists.xml.org/archives/xml-dev/ To subscribe or unsubscribe from this list use the subscription manager: <http://lists.xml.org/ob/adm.pl>
|

Cart



