title: XML Parsing - Read a Simple XML File and Retrieve Values
body: <p>I've written a Task Scheduling program for learning purposes. Currently I'm saving the scheduled tasks just as plain text and then parsing it using Regex. This looks messy (code wise) and is not very coherent. </p>
  
  <p>I would like to load the scheduled tasks from an XML file instead, I've searched quite a bit to find some solutions but I couldn't get it to work how I wanted. </p>
  
  <p>I wrote an XML file structured like this to store my data in:</p>
  
  <pre><code>&lt;Tasks&gt;
      &lt;Task&gt;
          &lt;Name&gt;Shutdown&lt;/Name&gt;
          &lt;Location&gt;C:/WINDOWS/system32/shutdown.exe&lt;/Location&gt;
          &lt;Arguments&gt;-s -f -t 30&lt;/Arguments&gt;
          &lt;RunWhen&gt;
              &lt;Time&gt;8:00:00 a.m.&lt;/Time&gt;
              &lt;Date&gt;18/03/2011&lt;/Date&gt;
              &lt;Days&gt;
                  &lt;Monday&gt;false&lt;/Monday&gt;
                  &lt;Tuesday&gt;false&lt;/Tuesday&gt;
                  &lt;Wednesday&gt;false&lt;/Wednesday&gt;
                  &lt;Thursday&gt;false&lt;/Thursday&gt;
                  &lt;Friday&gt;false&lt;/Friday&gt;
                  &lt;Saturday&gt;false&lt;/Saturday&gt;
                  &lt;Sunday&gt;false&lt;/Sunday&gt;
                  &lt;Everyday&gt;true&lt;/Everyday&gt;
                  &lt;RunOnce&gt;false&lt;/RunOnce&gt;
              &lt;/Days&gt;
          &lt;/RunWhen&gt;
          &lt;Enabled&gt;true&lt;/Enabled&gt;
      &lt;/Task&gt;
  &lt;/Tasks&gt;
  </code></pre>
  
  <p>The way I'd like to parse the data is like so:</p>
  
  <blockquote>
    <ol>
    <li>Open Tasks.xml </li>
    <li>Load the first Task tag.</li>
    <li>In that task retrieve the values of the Name, Location and Arguments tags.</li>
    <li>Then open the RunWhen tag and retrieve the values of the Time and Date tags.</li>
    <li>After that open the Days tag and retrieve the value of each individual tag within.</li>
    <li>Retrieve the value of Enabled.</li>
    <li>Load the next task and repeat steps 3 -> 7 until all the Task tags in Tasks have been parsed.</li>
    </ol>
  </blockquote>
  
  <p>I'm very sure you can do it this way I just can't work it out as there are so many different ways to do things in XML I got a bit overwhelmed. But what I've go so far is that I would most likely be using XPathDocument and XPathNodeIterator right?</p>
  
  <p>If someone can show me an example or explain to me how this would be done I would be very happy.</p>