Click here to Skip to main content
15,900,461 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,
I want to insert,update and delete xml data using C#.net can u guide me or send any snippets
Posted

 
Share this answer
 
 
Share this answer
 
 
Share this answer
 
Comments
chitransh635 18-Sep-12 5:53am    
sir i had developed a website in 2 tier architecture but now clients wants that this website shoul also run offline ..please give some idea, how to accomplish this task
[no name] 18-Sep-12 7:20am    
i have no idea about how the aps.net application offline runs..

but i know one think but it very sticky,unsecure and complicated so this i cant explain
yes i have done this using text box i can share my code with you

C#
public bool updateNode(String objName, String objSheetNames)
        {
            XmlDocument objXMLDocument = new XmlDocument();
            objXMLDocument.Load(xmlPath);
            XmlNode objNode = null;
            ArrayList ls = searchNode(objName, objXMLDocument);
            String[] sheetNamesList = objSheetNames.Split(',');

            if (ls.Count != 0)            
            {
                objNode = (XmlNode)ls[0];
                XmlNode parentNode = objNode.ParentNode;
                XmlNode childNode = parentNode.LastChild;
                foreach (String val in sheetNamesList)
                {
                XmlNode appendedNode = objXMLDocument.CreateElement("SName");       
                appendedNode.InnerText = val;
                childNode.AppendChild(appendedNode);
                }
                objXMLDocument.Save(xmlPath);
                return true;
            }
            else
            {
                return false;
            }
        }


here i used "SNAME" as the name of my node which i wanted to update
and here is the code behind the button

C#
private void button4_Click(object sender, EventArgs e)
        {
            string objName = textBox1.Text;
            string objSheetNames = textBox2.Text;
            bool objverify = c.updateNode(objName, objSheetNames);
            if (objverify == true)
            {
                MessageBox.Show("Record Updated");
            }
            else
            {
                MessageBox.Show("Record Cannot be added.Already Exists");
            }
        }


i used the root node(objName ) for which child i wanted to update
 
Share this answer
 
sir i had developed a website in 2 tier architecture but now clients wants that this website should also run offline ..please give some idea or code, to accomplish this task
 
Share this answer
 
hi download this code from asp.net site here

http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/HoverMenu/HoverMenu.aspx[^]

in this example it explain details in which their is one grid having insert update and delete operation..in this example data is inserted,updated,deleted in xml file ..


i hope you got some hint..according to your requirement
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900