FIX: SAX MSXMLWriter Fails to Save Characters Under Certain Encoding (291370)



The information in this article applies to:

  • Microsoft XML 3.0
  • Microsoft XML 3.0 SP1

This article was previously published under Q291370

SYMPTOMS

When you call the parse or parseURL methods of the SAXXMLReader to parse XML data that contains characters that cannot be represented in the output encoding of the Simple API for XML (SAX) MSXMLWriter, you receive the following error message:
Unable to save character to 'iso-8859-1' encoding. -2147467259
For example, the error message occurs when the XML data contains the characters &#B9 FA; &#E1 BB; in GB2312 encoding while the output encoding for the SAX MSXMLWriter is set to ISO-8859-1.

CAUSE

The XML data contains a character that cannot be represented in the ISO-8859-1 character set.

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.

This bug was corrected in Microsoft XML 3.0 Service Pack 1.

For additional information on other fixes included in Microsoft XML 3.0 Service Pack 1, click the article number below to view the article in the Microsoft Knowledge Base:

292935 INFO: List of Issues Fixed in Microsoft XML 3.0 Service Pack 1

For the latest information and downloads of MSXML, refer to the following Web site:

MORE INFORMATION

The following file is available for download from the Microsoft Download Center:
Release Date: Jun-22-2001

For additional information about how to download Microsoft Support files, click the following article number to view the article in the Microsoft Knowledge Base:

119591 How to Obtain Microsoft Support Files from Online Services

Microsoft scanned this file for viruses. Microsoft used the most current virus-detection software that was available on the date that the file was posted. The file is stored on security-enhanced servers that help to prevent any unauthorized changes to the file.

Steps to Reproduce Behavior

  1. Create the test XML document. To do this, download the Gb2312.xml file and move the file to the root folder of drive C.
  2. Create the test project:
    1. In Microsoft Visual Basic, create a new Standard EXE project. Form1 is created by default.
    2. On the Project menu, click to select References, and then select Microsoft ActiveX Data Objects 2.6 Library and Microsoft XML, v3.0.
    3. Add a CommandButton to Form1. Command1 is added by default.
    4. Paste the following code into the Click() event for Command1:
      Private Sub Command1_Click()
          
          Dim writer As New MXXMLWriter30
          Dim reader As New SAXXMLReader30
          Dim adoStr As New ADODB.Stream
             
          adoStr.Type = adTypeBinary
          adoStr.Open
      
          writer.output = adoStr
          writer.encoding = "iso-8859-1"
                   
          On Error GoTo ErrHandler
                 
          Set reader.contentHandler = writer
          
          reader.parseURL "c:\gb2312.xml"
          Debug.Print adoStr.Size
          
          Set writer = Nothing
          Set reader = Nothing
          Set adoStr = Nothing
      
          Exit Sub
          
      ErrHandler:
          MsgBox Err.Description & Err.Number
      End Sub
      						
  3. Test:
    1. Press the F5 key to run the Visual Basic project.
    2. Click the CommandButton, and note that you receive the following error message:
      Unable to save character to 'iso-8859-1' encoding. -2147467259

Modification Type:MinorLast Reviewed:8/9/2004
Keywords:kbdownload kbdownload kbBug kbfix KbMSXML300SP1fix kbMSXMLnosweep KB291370