how to read from Xml File and put the list of element in listView on the form
<p>i have my xml file "modules.xml", from which i m trying to load the Name of every module in the listView in my form. i have tried the following code, its not giving me error neither working at all.</p>

<p>modules.xml</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
&lt;Modules&gt;
  &lt;Module&gt;
    &lt;Code&gt;3SFE504&lt;/Code&gt;
    &lt;Name&gt;Algorithms and Data Structures&lt;/Name&gt;
    &lt;Capacity&gt;5&lt;/Capacity&gt;
    &lt;Semester&gt;1&lt;/Semester&gt;
    &lt;Prerequisites&gt;none&lt;/Prerequisites&gt;
    &lt;LectureSlot&gt;Monday 9-11&lt;/LectureSlot&gt;
    &lt;TutorialSlot&gt;Monday 11-1pm&lt;/TutorialSlot&gt;
  &lt;/Module&gt; -
  &lt;Module&gt;
    &lt;Code&gt;3SFE508&lt;/Code&gt;
    &lt;Name&gt;3D Graphics 1&lt;/Name&gt;
    &lt;Capacity&gt;5&lt;/Capacity&gt;
    &lt;Semester&gt;1&lt;/Semester&gt;
    &lt;Prerequisites&gt;none&lt;/Prerequisites&gt;
    &lt;LectureSlot&gt;Monday 2-4pm&lt;/LectureSlot&gt;
    &lt;TutorialSlot&gt;Monday 4-6pm&lt;/TutorialSlot&gt;
  &lt;/Module&gt; -
  &lt;Module&gt;
    &lt;Code&gt;3SFE513&lt;/Code&gt;
    &lt;Name&gt;Event-Driven Programming&lt;/Name&gt;
    &lt;Capacity&gt;10&lt;/Capacity&gt;
    &lt;Semester&gt;1&lt;/Semester&gt;
    &lt;Prerequisites&gt;none&lt;/Prerequisites&gt;
    &lt;LectureSlot&gt;Tuesday 9-11&lt;/LectureSlot&gt;
    &lt;TutorialSlot&gt;Tuesday 11-1pm&lt;/TutorialSlot&gt;
  &lt;/Module&gt;
  &lt;Module&gt;
    &lt;Code&gt;3SFE514&lt;/Code&gt;
    &lt;Name&gt;Object-Oriented Design&lt;/Name&gt;
    &lt;Capacity&gt;10&lt;/Capacity&gt;
    &lt;Semester&gt;1&lt;/Semester&gt;
    &lt;Prerequisites&gt;none&lt;/Prerequisites&gt;
    &lt;LectureSlot&gt;Tuesday 2-4pm&lt;/LectureSlot&gt;
    &lt;TutorialSlot&gt;Tuesday 4-6pm&lt;/TutorialSlot&gt;
  &lt;/Module&gt; -
  &lt;Module&gt;
    &lt;Code&gt;3SFE516&lt;/Code&gt;
    &lt;Name&gt;Requirements Engineering&lt;/Name&gt;
    &lt;Capacity&gt;10&lt;/Capacity&gt;
    &lt;Semester&gt;1&lt;/Semester&gt;
    &lt;Prerequisites&gt;none&lt;/Prerequisites&gt;
    &lt;LectureSlot&gt;Thursday 9-11&lt;/LectureSlot&gt;
    &lt;TutorialSlot&gt;Thursday 11-1pm&lt;/TutorialSlot&gt;
  &lt;/Module&gt;
  &lt;Module&gt;
    &lt;Code&gt;3SFE599&lt;/Code&gt;
    &lt;Name&gt;Introduction to AI&lt;/Name&gt;
    &lt;Capacity&gt;5&lt;/Capacity&gt;
    &lt;Semester&gt;1&lt;/Semester&gt;
    &lt;Prerequisites&gt;none&lt;/Prerequisites&gt;
    &lt;LectureSlot&gt;Thursday 2-4pm&lt;/LectureSlot&gt;
    &lt;TutorialSlot&gt;Monday 9-11&lt;/TutorialSlot&gt;
  &lt;/Module&gt; -
  &lt;Module&gt;
    &lt;Code&gt;3SFE540&lt;/Code&gt;
    &lt;Name&gt;Java Mobile Application Development&lt;/Name&gt;
    &lt;Capacity&gt;5&lt;/Capacity&gt;
    &lt;Semester&gt;1&lt;/Semester&gt;
    &lt;Prerequisites&gt;3SFE514&lt;/Prerequisites&gt;
    &lt;LectureSlot&gt;Monday 11-1pm&lt;/LectureSlot&gt;
    &lt;TutorialSlot&gt;Monday 2-4pm&lt;/TutorialSlot&gt;
  &lt;/Module&gt;
  &lt;Module&gt;
    &lt;Code&gt;3SFE541&lt;/Code&gt;
    &lt;Name&gt;C# .Net Framework Programming&lt;/Name&gt;
    &lt;Capacity&gt;5&lt;/Capacity&gt;
    &lt;Semester&gt;1&lt;/Semester&gt;
    &lt;Prerequisites&gt;3SFE514&lt;/Prerequisites&gt;
    &lt;LectureSlot&gt;Monday 4-6pm&lt;/LectureSlot&gt;
    &lt;TutorialSlot&gt;Tuesday 9-11&lt;/TutorialSlot&gt;
  &lt;/Module&gt;
  &lt;Module&gt;
    &lt;Code&gt;3SFE515&lt;/Code&gt;
    &lt;Name&gt;Software Engineering Group Project&lt;/Name&gt;
    &lt;Capacity&gt;5&lt;/Capacity&gt;
    &lt;Semester&gt;2&lt;/Semester&gt;
    &lt;Prerequisites&gt;3SFE514&lt;/Prerequisites&gt;
    &lt;LectureSlot&gt;Monday 9-11&lt;/LectureSlot&gt;
    &lt;TutorialSlot&gt;Monday 11-1pm&lt;/TutorialSlot&gt;
  &lt;/Module&gt;
  &lt;Module&gt;
    &lt;Code&gt;3SFE519&lt;/Code&gt;
    &lt;Name&gt;Software Engineering&lt;/Name&gt;
    &lt;Capacity&gt;10&lt;/Capacity&gt;
    &lt;Semester&gt;2&lt;/Semester&gt;
    &lt;Prerequisites&gt;none&lt;/Prerequisites&gt;
    &lt;LectureSlot&gt;Monday 2-4pm&lt;/LectureSlot&gt;
    &lt;TutorialSlot&gt;Monday 4-6pm&lt;/TutorialSlot&gt;
  &lt;/Module&gt;
  &lt;Module&gt;
    &lt;Code&gt;3SFE542&lt;/Code&gt;
    &lt;Name&gt;Mobile User Interface Development&lt;/Name&gt;
    &lt;Capacity&gt;5&lt;/Capacity&gt;
    &lt;Semester&gt;2&lt;/Semester&gt;
    &lt;Prerequisites&gt;3SFE540&lt;/Prerequisites&gt;
    &lt;LectureSlot&gt;Tuesday 9-11&lt;/LectureSlot&gt;
    &lt;TutorialSlot&gt;Tuesday 11-1pm&lt;/TutorialSlot&gt;
  &lt;/Module&gt;
  &lt;Module&gt;
    &lt;Code&gt;3MTS594&lt;/Code&gt;
    &lt;Name&gt;Interactive Multimedia&lt;/Name&gt;
    &lt;Capacity&gt;5&lt;/Capacity&gt;
    &lt;Semester&gt;2&lt;/Semester&gt;
    &lt;Prerequisites&gt;none&lt;/Prerequisites&gt;
    &lt;LectureSlot&gt;Tuesday 2-4pm&lt;/LectureSlot&gt;
    &lt;TutorialSlot&gt;Tuesday 4-6pm&lt;/TutorialSlot&gt;
  &lt;/Module&gt;
  &lt;Module&gt;
    &lt;Code&gt;3SFE555&lt;/Code&gt;
    &lt;Name&gt;Concurrent Programming&lt;/Name&gt;
    &lt;Capacity&gt;5&lt;/Capacity&gt;
    &lt;Semester&gt;2&lt;/Semester&gt;
    &lt;Prerequisites&gt;none&lt;/Prerequisites&gt;
    &lt;LectureSlot&gt;Thursday 9-11&lt;/LectureSlot&gt;
    &lt;TutorialSlot&gt;Thursday 11-1pm&lt;/TutorialSlot&gt;
  &lt;/Module&gt;
  &lt;Module&gt;
    &lt;Code&gt;3SFE557&lt;/Code&gt;
    &lt;Name&gt;Mobile Gaming&lt;/Name&gt;
    &lt;Capacity&gt;10&lt;/Capacity&gt;
    &lt;Semester&gt;2&lt;/Semester&gt;
    &lt;Prerequisites&gt;none&lt;/Prerequisites&gt;
    &lt;LectureSlot&gt;Thursday 9-11&lt;/LectureSlot&gt;
    &lt;TutorialSlot&gt;Monday 9-11&lt;/TutorialSlot&gt;
  &lt;/Module&gt;
  &lt;Module&gt;
    &lt;Code&gt;3SFE500&lt;/Code&gt;
    &lt;Name&gt;Intelligent Systems&lt;/Name&gt;
    &lt;Capacity&gt;10&lt;/Capacity&gt;
    &lt;Semester&gt;2&lt;/Semester&gt;
    &lt;Prerequisites&gt;3SFE599&lt;/Prerequisites&gt;
    &lt;LectureSlot&gt;Monday 11-1pm&lt;/LectureSlot&gt;
    &lt;TutorialSlot&gt;Monday 2-4pm&lt;/TutorialSlot&gt;
  &lt;/Module&gt;
  &lt;Module&gt;
    &lt;Code&gt;3SFE501&lt;/Code&gt;
    &lt;Name&gt;3D Graphics II&lt;/Name&gt;
    &lt;Capacity&gt;10&lt;/Capacity&gt;
    &lt;Semester&gt;2&lt;/Semester&gt;
    &lt;Prerequisites&gt;3SFE508&lt;/Prerequisites&gt;
    &lt;LectureSlot&gt;Monday 4-6pm&lt;/LectureSlot&gt;
    &lt;TutorialSlot&gt;Tuesday 9-11&lt;/TutorialSlot&gt;
  &lt;/Module&gt;
&lt;/Modules&gt;
</code></pre>

<p>.cs file is </p>

<pre><code>using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Xml;
using System.IO;

namespace cw
{
    public partial class Form1 : Form
    {    
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            String workingDir = Directory.GetCurrentDirectory();
            XmlTextReader textReader = new XmlTextReader(workingDir + @"\modules.xml");
            XmlNodeType type;

            Console.WriteLine("BaseURI:" + textReader.BaseURI);


            while (textReader.Read())
            {
                type = textReader.NodeType;


                if (type == XmlNodeType.Element)
                {
                    if (textReader.Name == "Name")
                    {
                        textReader.Read();
                        listView1.Items.Add(textReader.Value);
                    }


                }
            }
            Console.ReadLine();
            textReader.Close();
        }

    }
}
</code></pre>

<p>i carried out a text and concluded that my while loop is working but the if statment isn't working.</p>
