atom feed2 messages in com.googlegroups.dotnetdevelopmentAn unhandled exception of type 'Syste...
FromSent OnAttachments
weird0Mar 3, 2007 8:48 am 
Joe EnosMar 5, 2007 11:53 am 
Subject:An unhandled exception of type 'System.StackOverflowException' occurred in XmlTest.exe
From:weird0 (amir@gmail.com)
Date:Mar 3, 2007 8:48:14 am
List:com.googlegroups.dotnetdevelopment

I am trying to parse an xml string but it gives the error as mentioned above. What should I do? How do i fix this System.StackOverFlowException? Here is the code for reading,writing and error point.

public string CreateXmlString(string branch,string amount,string datetime,string Accno,string pincode) { StringBuilder strbuilder = new StringBuilder(); //strbuilder.Append("<xml version="1.0" utf- encoding="">"); strbuilder.Append("\n"); strbuilder.Append("<atm>"); strbuilder.Append("\n"); strbuilder.Append("<branch>"); strbuilder.Append(branch); strbuilder.Append("</branch>"); strbuilder.Append("\n"); strbuilder.Append("<amount>"); strbuilder.Append(amount); strbuilder.Append("</amount>"); strbuilder.Append("\n"); strbuilder.Append("<datetime>"); strbuilder.Append(datetime); strbuilder.Append("</datetime>"); strbuilder.Append("\n"); strbuilder.Append("<accno>"); strbuilder.Append(Accno); strbuilder.Append("</accno>"); strbuilder.Append("\n"); strbuilder.Append("<pincode>"); strbuilder.Append(pincode); strbuilder.Append("</pincode>"); strbuilder.Append("\n"); strbuilder.Append("<balance>"); strbuilder.Append(pincode); strbuilder.Append("</balance>"); strbuilder.Append("\n"); strbuilder.Append("</atm>");

return strbuilder.ToString(); }

public void ReadXmlString(string xmlString) { // atmInfo = new ATM_Info(); // ATMInfo atmInfo = new ATMInfo(); /* XPathNavigator nav; XPathDocument docnav=new XPathDocument(xmlString); nav = docnav.CreateNavigator(); nav.MoveToRoot(); nav.MoveToFirstChild(); atmInfo.Branch = nav.GetAttribute("branch", ""); */ // Console.WriteLine(attr); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(xmlString); //XmlReader tr =xmldoc.OuterXml;

XmlReader tr = XmlReader.Create(new StringReader(xmlDoc.OuterXml)); //XmlTextReader tr = (XmlTextReader)XmlReader.Create("accholder"); // XmlReader tr=nav.ReadSubtree(); while (!tr.EOF) { // if we hit an element type we will store it in a variable

if (tr.MoveToContent() == XmlNodeType.Element && tr.Name == "accno") { atmInfo.Accno = tr.ReadElementString(); } if (tr.MoveToContent() == XmlNodeType.Element && tr.Name == "amount") { atmInfo.Amount = tr.ReadElementString(); } if (tr.MoveToContent() == XmlNodeType.Element && tr.Name == "date_trans") { atmInfo.Datetime = tr.ReadElementString(); } if (tr.MoveToContent() == XmlNodeType.Element && tr.Name == "pincode") { atmInfo.PinCode = tr.ReadElementString(); } else { // otherwise move on tr.Read(); }

The error point:

class ATMInfo { public string Accno { get { return Accno; } set { Accno=value; } } public string Amount { get { return Amount; } // point of error set { Amount=value; } } public string Datetime { get { return Datetime; } set { Datetime=value; } } public string PinCode { get { return PinCode; } set { PinCode=value; } }