Re: Encoding switch error (FIXED)

admin

Administrator
Staff member
I found my own answer. In case anyone in the near future has this problem,it is due to the version of the XML parser. According to MS KB Article Q275883,versions 2.5 & 2.6 will give this error because the "loadXML method of IXMLDOMDocumentcan only load UTF-16 or UCS-2 encoded data".I installed ver 3.0 of the XML Parser and my error disappeared."Bob Rouse" <[email protected]> wrote:>>I am using DOM in VB to access an XML file. The heading in the XML filecontains>this:><?xml version="1.0" encoding="UTF-8" ?>>When I try to open the file, I get the error "Switch from current encoding>to specified encoding not supported". If I remove the 'encoding="UTF-8"'>parameter, it works fine. Unfortunately, I am not at liberty to do thatin>a real production environment.>>I cannot find any answers in the MSDN documentation. I am a seasoned VBprogrammer>who is relatively new to XML.>>Here is the code I am using:>> Dim objDoc as DOMDocument> Dim intFile as Integer> Dim strFileText as String>> ' Move file text into a string> Open "D:\Test.xml" For Input As intFile> strFileText = input(LOF(intFile), intFile)> Close intFile>> ' Initialize DOM Document object> Set objDoc = New DOMDocument>> ' Load text string into DOM object> If Not objDoc.loadXML(strFileText) Then> strErrMsg = objDoc.parseError.reason> ' <Error formating, etc...>> End If>>Any help is appreciated...>>
 
Back
Top