title: Using XmlTextReader
body: <p>I am a beginner programmer starting off with C#, and web services. </p>
  
  <p>In the <code>Service.cs</code> file of my web service, I create a <code>ReadXMLFile()</code> method where I am trying to read an existing XML file, take the data from it and place it to the corresponding properties (DataMembers) that I created in the <code>IService.cs</code> file. </p>
  
  <p>My problem is that my code is basically not doing anything. I've tried looking for web sites and tutorials on this but there really isn't much out there, especially for a beginner like myself. Anyone have any idea how I should go about this, because what I've been trying so far is obviously wrong. </p>
  
  <p>Below is my <code>ReadXMLFile()</code> method.  </p>
  
  <pre><code>void ReadXMLFile()
  {
      XmlTextReader reader = new XmlTextReader("ClassRoll.xml");
      reader.Read();
      while (reader.Read())
      {
          if (reader.Name == "id")
          {
              id = reader.ReadString();
          }
          else if (reader.Name == "firstname")
          {
              link = reader.ReadString();
          }
          else if (reader.Name == "lastname")
          {
              description = reader.ReadString();
          }
          else if (reader.Name == "count")
          {
              description = reader.ReadString();
          }
          else if (reader.Name == "testscore")
          {
              description = reader.ReadString();
          }
      }
  }
  </code></pre>
  
  <p>this is an example of my xml file</p>
  
  <pre><code>&lt;classroll&gt;
    &lt;student&gt;
      &lt;id&gt;101010&lt;/id&gt;
      &lt;lastname&gt;Smith&lt;/lastname&gt;
      &lt;firstname&gt;Joe&lt;/firstname&gt;
      &lt;testscores count="5"&gt;
        &lt;score&gt;65&lt;/score&gt;
        &lt;score&gt;77&lt;/score&gt;
        &lt;score&gt;67&lt;/score&gt;
        &lt;score&gt;64&lt;/score&gt;
        &lt;score&gt;80&lt;/score&gt;
      &lt;/testscores&gt;
    &lt;/student&gt;
  &lt;/classroll&gt;
  </code></pre>