Hi,,
This is exactly what I am doing now ,,but the problwm is that before doing
this I am reading the xml document by using the following code
====================Start of Code=====================
XmlTextReader reader = new XmlTextReader("AppSetting.xml");
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Element)
{
switch (reader.Name)
{
case "ConnectionString":
{
applicationVars.ConnectionString = reader.ReadElementString().Trim();
break;
}
}
}
reader.Close();
====================End of Code=====================
then I try to update an element using your code but I get this Error:
the procescan not access " " because it is being used by anotheprocess
Thanks for your help.
ALI
"Nigel Armstrong" <Ni************@discussions.microsoft.com> wrote in
message news:E9**********************************@microsof t.com...
Hi ALI
DOM will probably do what you want - unless your documents are
large...code follows
HTH
Nigel
Document test.xml
<?xml version='1.0' encoding='utf-8' ?>
<root><test>Old</test></root>
//DOM code
System.Xml.XmlDocument d = new System.Xml.XmlDocument();
d.Load(@"C:\test.xml");
System.Xml.XmlElement el =
(System.Xml.XmlElement)d.GetElementsByTagName("tes t")[0]; el.InnerText = "New";
d.Save(@"C:\test.xml");
"ALI-R" wrote:
Hi
what is the easiest way of changing the value of an element in an xml
file using C#?
thanks for your help.
ALI