本文介绍了XmlRead设置错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我正在尝试使用xml架构验证xml文档。我的代码如下所示:


Hi, I'm trying to validate a xml document using xml schemas. My code looks like this:

XmlTextReader textReader = new XmlTextReader(" text.xml");

settings = new XmlReaderSettings();
settings.ValidationType = ValidationType.Schema;
settings.Schemas.Add(null," schema.xsd");

xmlReader = XmlReader.Create(textReader,settings );

while(xmlReader.Read()){}
XmlTextReader textReader = new XmlTextReader("text.xml");

settings = new XmlReaderSettings();
settings.ValidationType = ValidationType.Schema;
settings.Schemas.Add(null, "schema.xsd");

xmlReader = XmlReader.Create(textReader, settings);

while (xmlReader.Read()) { }

推荐答案




Code Snippet


这篇关于XmlRead设置错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 19:50