how to reade and write data in xml file by using c sharp

Posted by rameshmandapelly-7781 under C# on 6/10/2011 | Points: 10 | Views : 2190 | Status : [Member] | Replies : 1
how to reade and write data in xml file by using c sharp
i have taken a window form and empid empname text fields .also one save button now i have to read and write and save in xml file
previesly send links were not full field my requirements please send use ful information




Responses

Posted by: Seenuvasan on: 6/10/2011 [Member] Starter | Points: 25

Up
0
Down
Read xml file code is below:



copy xml file and paste it in debug folder

using System.Xml; //add reference

class Program
{
static void Main(string[] args)
{
XmlTextReader reader = new XmlTextReader ("name.xml");
while (reader.Read())
{
switch (reader.NodeType)
{
case XmlNodeType.Element:
Console.Write("<" + reader.Name);
Console.WriteLine(">");
break;
case XmlNodeType.Text: //Display the text in each element.
Console.WriteLine (reader.Value);
break;
case XmlNodeType. EndElement: //Display the end of the element.
Console.Write("</" + reader.Name);
Console.WriteLine(">");
break;
}
}
}
}


Thanks,
Seen

rameshmandapelly-7781, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response