I'm trying to check my xml against it xsd and get an invalid error character in this encoding. The code I use for verification is below:
private static void ValidatingProcess(string XSDPath, string xml)
{
MemoryStream stream =
new MemoryStream(ASCIIEncoding.Default.GetBytes(xml));
using (StreamReader SR = new StreamReader(XSDPath))
{
XmlSchema Schema = XmlSchema.Read(SR, ReaderSettings_ValidationEventHandler);
XmlReaderSettings ReaderSettings = new XmlReaderSettings();
ReaderSettings.ValidationType = ValidationType.Schema;
ReaderSettings.Schemas.Add(Schema);
ReaderSettings.ValidationEventHandler += ReaderSettings_ValidationEventHandler;
XmlReader objXmlReader = XmlReader.Create(stream, ReaderSettings);
bool notDone = true;
while (notDone)
{
notDone = objXmlReader.Read();
}
}
}
Errors on characters like é, so I guessed that it was the fact that UTF-8 was specified as an encoding or a way to create a MemoryStream in the above code with ASCIIEncoding. I tried changing the encoding of both xsd and xml to UTF-16 and memystream to UTF32, but this seems to have no effect. Any ideas?
PeteT source
share