如何在C#中进行无名称空间的简单XML模式验证
||
我已经使用xsd.exe生成了一组类,并根据生成的代码创建了XML文档。我现在想针对原始xsd验证序列化的类实例。
我的XML是这样的:
<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<MyRoot xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">
-- rest of XML document here
</MyRoot>
我的XSD是这样的:
<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">
<xs:element name=\"MyRoot\" type=\"MyRootType\"/>
-- MyRootType definition and rest of XSD
</xs:schema>
当我尝试使用XmlReader验证XML时,出现以下错误:
\“未声明\'MyRoot \'元素。\”
有什么事吗
没有找到相关结果
已邀请:
2 个回复
贸会
这样,验证工具就会知道在哪里可以找到XSD来验证XML。
烫珊