Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Fatal XML Parse Error: Invalid character (Unicode: 0x1D)

From: Martin Honnen <mahotrash@-----.-->
To: NULL
Date: 11/6/2009 12:00:00 PM
JR wrote:
> I apologize up front for not being much of an XML guy.  We are trying to use 
> a canned solution to send barcode strings via XML.  The canned solution works 
> fine.  The one issue we are having is that the barcodes are GS1 compliant 
> meaning we have ASCII character 29 (0x1D) embedded in our barcodes.  We want 
> these strings to contain the character, but the parser just doesn't like them.
> 
> Our heading is as follows:
> <?xml version="1.0" encoding="utf-8" ?> 
> 
> Anyone know of a means of passing such characters in an XML string?

XML 1.0 does not allow that character.
I think XML 1.1 allows it if escaped with a character reference
  (e.g. & # x 1 D;, without the spaces). However Microsoft does not have 
parsers that support XML 1.1.

With the Microsoft .NET framework 2.0 or later you should also be able 
to use version="1.0", escape the character as shown above and then parse 
it with an XmlReader with XmlReaderSettings where CheckCharacters is set 
to false:

             XmlReaderSettings xrs = new XmlReaderSettings();
             xrs.CheckCharacters = false;

             using (XmlReader xr = XmlReader.Create("input.xml", xrs))
             {
                ...
             }


The proper way with XML 1.0 however would be to base64 encode such 
characters, that way you would be able to pass the file around as XML 
1.0 and any XML parser can deal with it.

-- 

	Martin Honnen --- MVP XML
	http://msmvps.com/blogs/martin_honnen/


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent