LarissaB1965
New Member
When I try and update a value in my XML document, instead of editing the existing value, it keeps inserting a new node with my new values. If have tried this two ways with the same results...\[code\]var doc = XDocument.Parse(xmlString);XElement shippingElement = (from xml2 in doc .Elements("extradata").Elements("SharedCustomAppData") .Elements("clsNameValues").Elements("clsnamevalue")where xml2.Element("name").Attribute("Value").Value =http://stackoverflow.com/questions/14513150/="SHOP_FLOOR_INSTR"select xml2).FirstOrDefault();shippingElement.Element("value").Attribute("Value").Value = "http://stackoverflow.com/questions/14513150/Changed!";\[/code\]And\[code\]XmlDocument xmlDoc = new XmlDocument();xmlDoc.LoadXml(oLine.ExtraData);XmlNodeList nodes = xmlDoc.SelectNodes( "extradata/SharedCustomAppData/clsNameValues/clsnamevalue");foreach (XmlNode node in nodes){XmlNode nameNode = node.SelectSingleNode("name");if (nameNode != null && nameNode.Attributes["Value"].Value =http://stackoverflow.com/questions/14513150/="SHOP_FLOOR_INSTR"){ XmlNode valueNode = node.SelectSingleNode("value"); if (valueNode != null) { valueNode.Attributes["Value"].Value = http://stackoverflow.com/questions/14513150/line.SHOP_FLOOR_INSTR; }}}\[/code\]The section of XML I'm trying to update looks like this:\[code\] <SharedCustomAppData> <clsNameValues> <clsnamevalue> <name Value="http://stackoverflow.com/questions/14513150/SHOP_FLOOR_INSTR" /> <value Value="http://stackoverflow.com/questions/14513150/Current value" /> </clsnamevalue> </clsNameValues> </SharedCustomAppData>\[/code\]