I need to succesfully validate my xml file against xsd schema in C#
<p>when i run the code after adding both xml and xsd schema file i get the error as "ID" attribute not declared,The element 'Student' has invalid child element 'Student'.
Validation failed
below is my code:</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?xml version="1.0" encoding="utf-8" standalone="yes"?&gt;
&lt;Students&gt;
  &lt;Student ID="101"&gt;
    &lt;Name&gt;kamal&lt;/Name&gt;
    &lt;Gender&gt;Male&lt;/Gender&gt;
    &lt;Marks&gt;800&lt;/Marks&gt;
  &lt;/Student&gt;
  &lt;Student ID="102"&gt;
    &lt;Name&gt;Sapna&lt;/Name&gt;
    &lt;Gender&gt;Female&lt;/Gender&gt;
    &lt;Marks&gt;900&lt;/Marks&gt;
  &lt;/Student&gt;
  &lt;Student ID="103"&gt;
    &lt;Name&gt;Raju&lt;/Name&gt;
    &lt;Gender&gt;Male&lt;/Gender&gt;
    &lt;Marks&gt;870&lt;/Marks&gt;
    &lt;Student ID="104"&gt;
      &lt;Name&gt;Sushant&lt;/Name&gt;
      &lt;Gender&gt;Male&lt;/Gender&gt;
      &lt;Marks&gt;700&lt;/Marks&gt;
    &lt;/Student&gt;
  &lt;/Student&gt;
&lt;/Students&gt;</code></pre>
</div>
</div>
</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
&lt;xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
  &lt;xsd:element name="Students"&gt;
    &lt;xsd:complexType&gt;
      &lt;xsd:sequence&gt;
        &lt;xsd:element name="Student" minOccurs="1" maxOccurs="4"&gt;
          &lt;xsd:complexType&gt;
            &lt;xsd:sequence&gt;
              &lt;xsd:element name="Name" minOccurs="1" maxOccurs="1"/&gt;
              &lt;xsd:element name="Gender" minOccurs="1" maxOccurs="1"/&gt;
              &lt;xsd:element name="Marks" minOccurs="1" maxOccurs="1"/&gt;
            &lt;/xsd:sequence&gt;
          &lt;/xsd:complexType&gt;
        &lt;/xsd:element&gt;
      &lt;/xsd:sequence&gt;
    &lt;/xsd:complexType&gt;
  &lt;/xsd:element&gt;
&lt;/xsd:schema&gt;</code></pre>
</div>
</div>
</p>

<p>And finally the code file:</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
using System.Xml.Schema;

namespace ClassLibrary1
{
    class Class16
    {
        public static void Main()
        {
            XmlSchemaSet ss = new XmlSchemaSet();
            ss.Add("", @"C:\Users\admin\documents\visual studio 2013\Projects\ClassLibrary1\ClassLibrary1\Students.xsd");
             
            XDocument doc = XDocument.Load(@"C:\Users\admin\documents\visual studio 2013\Projects\ClassLibrary1\ClassLibrary1\sample1.xml");
             
            bool validationerror = false;
            doc.Validate(ss,(s,e)=&gt;
                {
                    Console.WriteLine(e.Message);
                   validationerror = true;
                });
            if(validationerror)
            {
                Console.WriteLine("Validation failed");
                Console.ReadLine();

            }
            else
            {
                Console.WriteLine("Validation succeded");
                Console.ReadLine();
            }

                
        }
    }
}</code></pre>
</div>
</div>
</p>