<P> Hi,</P>
<P> </P>
<P>I’m trying to read an XML file. How do i read through all the child nodes.</P>
<P>I have attached a sample of the XML file.</P>
<P>Please help!</P>
<P> </P>
<P><?xml version=“1.0” encoding=“UTF-8” ?> <BR>- <Payment DocumentType=“XML” Count=“2”><BR>- <RejectAccount Date=“2006-11-11” Status=“Rejected”><BR>- <Transaction TranNum=“1” Date=“2005-02-11”><BR> <ID>112</ID> <BR> <Name>Helen Trent</Name> <BR> <ValueDate>2006-08-20</ValueDate> <BR> <Credit>1250.00</Credit> <BR> </Transaction><BR>- <Transaction TranNum=“2” Date=“2006-04-11”><BR> <ID>10</ID> <BR> <Name>Sam Rivers</Name> <BR> <ValueDate>2005-08-20</ValueDate> <BR> <Credit>1251.00</Credit> <BR> </Transaction> <BR> </RejectAccount><BR> </Payment></P>
<P> </P>
<P> </P>
<P> </P>
<P>This is my code:</P>
<P> </P>
<P>static void Main(string[] args)<BR> {</P>
<P> XmlDocument doc = new XmlDocument();<BR> doc.Load(“C:\file.xml”);</P>
<P> <BR> XmlNodeList AcceptList = doc.GetElementsByTagName(“RejectAccount”);<BR> foreach (XmlNode node in RejectList)<BR> {<BR> XmlElement RejectAccountElement = (XmlElement)node;</P>
<P> string ID = “”;<BR> string Name = “”;<BR> string ValueDate = “”;<BR> string Credit = “”;<BR> </P>
<P> <BR> if (RejectAccountElement.HasChildNodes)<BR> {<BR> <BR> ID = RejectAccountACHElement.GetElementsByTagName(“ID”).InnerText;<BR> Name = RejectAccountElement.GetElementsByTagName(“Name”).InnerText;<BR> ValueDate = RejectAccountElement.GetElementsByTagName(“ValueDate”).InnerText;<BR> Credit = RejectAccountElement.GetElementsByTagName(“Credit”).InnerText;<BR> <BR> }<BR> <BR> <BR> Console.WriteLine("{0} {1} {2} {3} ", ID, Name, ValueDate, Credit);<BR></P>