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...

Micke BlomqvistRank #1,660 · 923 reputationPosted Feb 8, 2011, 9:34 AM EST
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);}
Sam HobbsRank #107 · 20.5K reputationPosted Feb 8, 2011, 12:25 PM EST
Nidhi Shah6 reputationPosted Feb 8, 2011, 7:00 PM EST
Micke BlomqvistRank #1,660 · 923 reputationPosted Feb 8, 2011, 8:45 PM EST
Vigneswar GV6 reputationPosted Mar 14, 2014, 12:23 AM EDT
Jignesh TrivediRank #16 · 50.3K reputationPosted Mar 14, 2014, 2:00 AM EDT
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.