hi...i m working on saving and retreiving of xml file...i have 3 edittexts
and two buttons....by entering values in all 3 edittexts and click on save
button,the data will saved to xml file...when i click on retrieve button the
stored data shud display in textview(like label)...the data is saving to xml
file and my problem is when i click on retreive it will shows only last
inserted record...not alll the records i inserted....and my code for 
retreiving is :

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Xml;

using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;

namespace XmlData
{
       [Activity(Label = "XmlDataOne",MainLauncher=true)]
    public class XmlOne : Activity
    {
           EditText eteno, etename, eteadd;
           Button btnsave, btnretrieve;
           TextView text;
           string path;           
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.XmlOne);
            // Create your application here
            eteno = FindViewById<EditText>(Resource.Id.etdeno1);
            etename = FindViewById<EditText>(Resource.Id.etdename1);
            eteadd = FindViewById<EditText>(Resource.Id.etdeadd1);
            btnsave = FindViewById<Button>(Resource.Id.Btndatasave);
            btnretrieve = FindViewById<Button>(Resource.Id.Btndataretreive);
            text = FindViewById<TextView>(Resource.Id.text);
            btnsave.Click += delegate { savexml(eteno.Text, etename.Text,
eteadd.Text); };
            btnretrieve.Click += delegate { retrXml(); };
        }

        private void retrXml()
        {
string path =
System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments),"Empp.xml");
            XmlDocument doc = new XmlDocument();
            doc.Load(path);
            XmlNode root = doc.DocumentElement;
            StringBuilder sb = new StringBuilder();
            XmlNodeList nodeList = root.SelectNodes("Employee");
            foreach(XmlNode node in nodeList){               
               
                sb.Append("Eno:");
                sb.Append(node.SelectSingleNode("Eno").InnerText);
                sb.Append("Ename:");
                sb.Append(node.SelectSingleNode("Ename").InnerText);
                sb.Append("Eadd:");
                sb.Append(node.SelectSingleNode("Eadd").InnerText);
                sb.Append("");                 
                      
            }
            text.Text =  sb.ToString();    
            // throw new NotImplementedException();       
   }
}

the output shows only last stored record ...when i insert data and click on
retrieve button it shows only last stored record ...i changed the code like:
 foreach(XmlNode node in nodeList){               
                sb.Append(sbs);
                sb.Append("Eno:");
                sb.Append(node.SelectSingleNode("Eno").InnerText);
                sb.Append("Ename:");
                sb.Append(node.SelectSingleNode("Ename").InnerText);
                sb.Append("Eadd:");
                sb.Append(node.SelectSingleNode("Eadd").InnerText);
                sb.Append("");
                sbs = sb.ToString();
                text.Text = sbs;               
            }
here m getting is when i insert record and click on retreive for each
inserted record the record is appending when i double click on retreive
button the last inserted record is appending again and again..

now my  problem is when i click on Retrieve button ,all inserted records
shud be display on textview not only the last inserted record...plz explain
me in detailed ...m new to .net also...plz reply as early as possible





--
View this message in context: 
http://mono-for-android.1047100.n5.nabble.com/Enhancement-in-Xml-Retreive-code-tp5712932.html
Sent from the Mono for Android mailing list archive at Nabble.com.
_______________________________________________
Monodroid mailing list
Monodroid@lists.ximian.com

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid

Reply via email to