我有xml發送到網頁,我想驗證幾個xsd,直到文件驗證。驗證後,我可以根據管理的驗證模式來確定xml文件的類型。對多個模式驗證未知的xml,直到找到匹配
List<string> xsdList = new List<string>();
xsdList.Add(_path + @"Handlers\DeviceSpecificHandlers\Schemas\Enquiry.xsd");
xsdList.Add(_path + @"Handlers\DeviceSpecificHandlers\Schemas\FingerDeleted.xsd");
xsdList.Add(_path + @"Handlers\DeviceSpecificHandlers\Schemas\Heartbeat.xsd");
xsdList.Add(_path + @"Handlers\DeviceSpecificHandlers\Schemas\Validation.xsd");
XmlSchemaSet schemas = new XmlSchemaSet();
foreach (string schema in xsdList)
{
var reader = new StringReader(File.ReadAllText(schema));
schemas.Add("", XmlReader.Create(reader));
}
request.Validate(schemas, (o, e) =>
{
match = false;
});
誰能幫助,上面是什麼香港專業教育學院拼湊起來的,到目前爲止,它目前拋出一個錯誤「System.Xml.Schema.XmlSchemaValidationException:全球元素‘接口’已經聲明」
有沒有一種方法可以獲得返回哪個模式的valiation成功?
謝謝你,這說明了一切。我對XSD驗證的理解很有意義。 – DavidB 2013-03-26 13:39:06