Hi All:
From the below XML file, i tried to change the value of each attribute "V" from button click but i end having a null value for V by using below methods:
<?xml version="1.0" encoding="utf-8"?>
<PP>
<G N="Default">
<P N="QuickLabSetNetwork" V="False" />
<P N="QuickLabActivation" V="" />
<P N="QuickLabMode" V="1" />
<P N="QuickLabDirectory" V="True" />
</G>
</PP
Method 1:
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(filenametoread);
XmlNode node = xmlDoc.SelectSingleNode("/PP/G/@N='QuickLabSetNetwork'/@V=''");
node.InnerText = "TTT";
xmlDoc.Save(filenametoread);
Method 2:
XElement xml = XElement.Load(filenametoread);
var lineItemXML = from x in xml.Descendants("PP")
select x;
foreach (XElement xe in lineItemXML)
{
Console.WriteLine(string.Format("N={0}, V={1}"
, xe.Element("G").Element("P").Element("N").Element("V").Value
)
);
}
Thanks in advance for yor your help.