XmlReaderSettings booksSettings = new XmlReaderSettings();
booksSettings.Schemas.Add("http://www.w3.org/2001/XMLSchema",XMLImportUsers.xsd");
booksSettings.ValidationType = ValidationType.Schema;
XmlReader books = XmlReader.Create(@"D:\test.xml",booksSettings);
while (books.Read()) { }
我的xsd
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="UserSettings">
<xs:complexType>
<xs:sequence>
<xs:element name="ID_UTENTE" type="xs:decimal" minOccurs="1" maxOccurs="1"/>
<xs:element name="ID_GRUPPO" type="xs:decimal" minOccurs="0" maxOccurs="1"/>
等等
你能帮助我并发布一个代码示例来从xsd中验证xls / xlsx吗? 提前谢谢
答案 0 :(得分:0)
为什么不使用OpenXML SDK打开XLSX文件? - https://github.com/OfficeDev/Open-XML-SDK
对于XLS,您有两种选择: