Try something like this:
1) Load your XsdSchema into a StreamReader
MemoryStream ms = new MemoryStream((new
Text.ASCIIEncoding()).GetBytes(XsdSchema));
StreamReader schemaReader = new StreamReader(ms);
2) Validate your XmlFragment on the StreamReader
XmlTextReader xmlReader = new XmlTextReader(new
System.IO.StringReader(XmlFragment));
XmlValidatingReader reader = new XmlValidatingReader(xmlReader);
reader.ValidationType = ValidationType.Schema;
reader.Schemas.Add (XmlSchema.Read(schemaReader, null));
while (reader.Read())
{}
reader.Close();
xmlReader.Close();
I hope it could help.
Lionel.
"Ward Bekker" <wa*********@replacethisEquanimity.nl> a écrit dans le message
de news: Oq****************@TK2MSFTNGP10.phx.gbl...
Hello,
I have two strings;
string XmlFragment; //contains the xml document
string XsdSchema; //contains the xsd schema
I would like to validate the XmlFragment against the XsdSchema. What is a
clean, simple way for accomplishing this?
Bye,
Ward