Csharp/C Sharp by API/System.Xml.Schema/XmlSchemaSet

Материал из .Net Framework эксперт
Версия от 15:08, 26 мая 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

XmlSchemaSet.Add

<source lang="csharp"> using System; using System.Linq; using System.Collections; using System.Collections.Generic; using System.Xml; using System.Xml.Schema; using System.Xml.Linq; using System.IO; public class MainClass {

   public static void Main() {
       string schema =
         @"<?xml version="1.0" encoding="utf-8"?>
   <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified"
        xmlns:xs="http://www.w3.org/2001/XMLSchema">
     <xs:element name="Books">
      <xs:complexType>
       <xs:sequence>
        <xs:element maxOccurs="unbounded" name="Book">
         <xs:complexType>
          <xs:sequence>
           <xs:element name="FirstName" type="xs:string" />
          <xs:element minOccurs="0" name="MiddleInitial"
               type="xs:string" />
             <xs:element name="LastName" type="xs:string" />
           </xs:sequence>
           <xs:attribute name="type" type="xs:string" use="required" />
         </xs:complexType>
       </xs:element>
      </xs:sequence>
     </xs:complexType>
    </xs:element>
   </xs:schema>";
       XmlSchemaSet schemaSet = new XmlSchemaSet();
       schemaSet.Add("", XmlReader.Create(new StringReader(schema)));
   }

}


 </source>