Re: XML encoding - handling foreign lang chars (SOLUTION)

admin

Administrator
Staff member
PROBLEM (restated):==================My client creates an XML doc in memory. It sends the xmldoc.xml string toan ASP on the server. The server does xmldoc.load(Request) and gets an error:"An invalid character was found in the text context." because the XML containsa foreign language character.SOLUTION========I tried having the client do an xmldoc.createProcessingInstruction and setthe encoding. Still got the error. Then I realized something.... xmldoc.xmlgives you a string that DOES NOT indicate the encoding!! SO, the encodingwas lost and the error continued.Now I do this:sXML = Replace(oXMLDoc.xml, "?>", " encoding=""ISO-8859-1""?>", 1, 1)Which adds the encoding to the <?xml version="1.0" ?> statement at the beginningof the doc (put there by the createProcessingInstruction). I send the sXMLstring to the ASP and...NOW IT WORKS!!! The xmldoc.load(Request) works without error!SIDE NOTES==========1) xmldoc.save("somefile.xml") DOES indeed retain the encoding, but xmldoc.xmldoes NOT.2) I use the Internet Transfer Control to send my XML to the server becausethe MSXML.XMLHTTPRequest requires IE and I don't want that requirement formy users. I could not figure out which DLLs of IE are really needed by MSXML.XMLHTTPRequest(its more than msxml.dll).
 
Back
Top