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/
Could you use [CDATA] for those parts which use special reserved chars ?
ismo
A control characterlike 0x1D is not a special reserved character, it is
not an allowed character. CDATA sections help to make your data more
readable as you can use
<foo><![CDATA[a < b && b < c]]></foo>
instead of
<foo>a < b && b < c</foo>
but they don't help to put in characters that are not allowed in XML.