How to read an XML file

Hi,

I’m trying to read an XML file. How do i read through all the child nodes.
I have attached a sample of the XML file.
Please help!

<?xml version=“1.0” encoding=“UTF-8” ?>

  • <Payment DocumentType=“XML” Count=“2”>
  • <RejectAccount Date=“2006-11-11” Status=“Rejected”>
  • <Transaction TranNum=“1” Date=“2005-02-11”>
    <ID>112</ID>
    <Name>Helen Trent</Name>
    <ValueDate>2006-08-20</ValueDate>
    <Credit>1250.00</Credit>
    </Transaction>
  • <Transaction TranNum=“2” Date=“2006-04-11”>
    <ID>10</ID>
    <Name>Sam Rivers</Name>
    <ValueDate>2005-08-20</ValueDate>
    <Credit>1251.00</Credit>
    </Transaction>
    </RejectAccount>
    </Payment>

This is my code:

static void Main(string[] args)
{
XmlDocument doc = new XmlDocument();
doc.Load(“C:\file.xml”);

        XmlNodeList AcceptList = doc.GetElementsByTagName("RejectAccount");
        foreach (XmlNode node in RejectList)
        {
            XmlElement RejectAccountElement = (XmlElement)node;
            string ID = "";
            string Name = "";
            string ValueDate = "";
            string Credit = "";
          
           
                if (RejectAccountElement.HasChildNodes)
                {
                    
  ID = RejectAccountACHElement.GetElementsByTagName("ID")*.InnerText;
Name = RejectAccountElement.GetElementsByTagName("Name")*.InnerText;
ValueDate = RejectAccountElement.GetElementsByTagName("ValueDate")*.InnerText;
Credit = RejectAccountElement.GetElementsByTagName("Credit")*.InnerText;
                  
                }
           
                
   Console.WriteLine("{0} {1} {2} {3} ", ID, Name, ValueDate,  Credit);