i am new to c# and xml. i have a xml file named names.xml like this
< teacher >Y
now i want to insert D into student tag. when i insert it will insert outside of students.
how can i insert D into students using c#. any idea or help please...
Jignesh TrivediPosted Mar 14, 2014, 6:00 AM
hi,
same thing you can achieve by using XmlTextReader and XmlDocument
Please refer
http://www.tutorialized.com/tutorial/Add-remove-elements-to-from-an-XML-Document-using-C/45101
hope this will help you.
Vigneswar GVPosted Mar 14, 2014, 4:23 AM
Micke BlomqvistPosted Feb 9, 2011, 1:45 AM
Nidhi ShahPosted Feb 9, 2011, 12:00 AM
Sam HobbsPosted Feb 8, 2011, 5:25 PM
Micke BlomqvistPosted Feb 8, 2011, 2:34 PM
Function C#:
try
{
using (DataSet ds = new DataSet())
{
ds.ReadXml("names.xml");
DataRow dr = ds.Tables["students"].NewRow();
dr[0] = "D";
ds.Tables["students"].Rows.Add(dr);
ds.AcceptChanges();
ds.WriteXml("names.xml");
}
}
catch(Exception rror)
{MessageBox.Show(rror.Message);}