Hello,
I'm trying to find the first attribute in an xml file that contains the string "name" (case insensitve) in it and then change its value.
Here is an example of my xmls
//XML 1
<CtApproachTypes
DataclassId="1992A9CE-B048-4676-BFD4-FD81F1A65401"
EntityId="1992A9CE-B048-4676-BFD4-FD81F1A65401"
Name="PAR"
Remark="No Remarks"></CT_ApproachTypes>
//XML 2
<MiMissions
DataclassId="C196A66B-4FA1-461C-9EEF-95A4F2085051"
EntityId="C196A66B-4FA1-461C-9EEF-95A4F2085051"
MissionName="Standard"
Visib="1"></MiMissions>
//XML 3
<StSituations
DataclassId="679FAC3C-C9EF-41FD-9A13-957915605F01"
EntityId="679FAC3C-C9EF-41FD-9A13-957915605F01"
Sname="Standard"
Status="C"
Template="1"></StSituations>
I wanna be able to modify the values of "Name", "MissionName", "Sname", and print them out to console
EDIT here is my code
public void updateXmlFile(string strFileName)
{
try
{
XmlDocument doc = new XmlDocument();
doc.Load(strFileName);
string newValue = GetUniqueKey();
XmlNodeList list = doc.SelectNodes("@*");
IEnumerable<XmlNode> filteredList= list.Cast<XmlNode>().Where(item=>item.Value.ToLower().Contains("name"));
foreach (XmlNode n in filteredList)
{
Console.WriteLine("NODES ARE : {0}", n);
}
doc.Save(strFileName);
}
catch (XmlException xex) { Console.WriteLine(xex); }
}
This didn't print out anything and I need still to modify the original value with the string newValue