OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   MSXML DOM Special Chars Less Than 32

[ Lists Home | Date Index | Thread Index ]
  • To: <xml-dev@lists.xml.org>
  • Subject: MSXML DOM Special Chars Less Than 32
  • From: "Mark Tucker" <MTucker@infoimage.com>
  • Date: Thu, 21 Mar 2002 15:53:45 -0700
  • Thread-index: AcHRK0Fi2yc9PteVRBi8uFxuVrUJ5w==
  • Thread-topic: 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@infoimage.com




 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS