Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - Fatal XML Parse Error: Invalid character (Unicode: 0x1D) [Thread Next] Re: Fatal XML Parse Error: Invalid character (Unicode: 0x1D)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/
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
