how to insert xml element, serial number automatically
<p>i used the following code to save data in xml,</p>

<pre><code>var path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "codedata.xml");
            XmlDocument doc = new XmlDocument();
            if (!System.IO.File.Exists(path))
            {                   
                XmlDeclaration declaration = doc.CreateXmlDeclaration("1.0", "UTF-8", "yes");
                XmlComment comment = doc.CreateComment("This is an XML Generated File");
                doc.AppendChild(declaration);
                doc.AppendChild(comment);
                doc.AppendChild(doc.CreateElement("Root"));
            }
            else
            {
                doc.Load(path);
            }
            XmlElement root = doc.DocumentElement;
            XmlElement Subroot = doc.CreateElement("data");
            XmlElement sno=doc.CreateElement("Sno");
            XmlElement Companycode = doc.CreateElement("Companycode");
            XmlElement Productcode = doc.CreateElement("Productcode");
            XmlElement Productname = doc.CreateElement("Productname");
            XmlElement Brandcode = doc.CreateElement("Brandcode");
            XmlElement Brandname = doc.CreateElement("Brandname");
            sno.InnerText = txt_sno.Text;
            Companycode.InnerText = txt_companycode.Text;
            Productcode.InnerText = txt_productcode.Text;
            Productname.InnerText = txt_productname.Text;
            Brandcode.InnerText = txt_brandcode.Text;
            Brandname.InnerText = txt_brandname.Text;
            Subroot.AppendChild(sno);
            Subroot.AppendChild(Companycode);
            Subroot.AppendChild(Productcode);
            Subroot.AppendChild(Productname);
            Subroot.AppendChild(Brandcode);
            Subroot.AppendChild(Brandname);
            root.AppendChild(Subroot);
            doc.AppendChild(root);
            doc.Save(path);
            MessageBox.Show("Details  added Successfully");
</code></pre>

<p>here i entered serial number manualy, i need it automatically. when i click the button, sno will increase the its number.
suggest me some idea.</p>
