I am trying to figure out how I can update my xml file. I know how to read and write, but I do not know how to update an existing record.
My xml file looks like this:
And I would like to be able to change the XAttribute value that is already in the file.
This is how I write the file:
XElement xElement; xElement = new XElement("Orders"); XElement element = new XElement( "Order", new XAttribute("Quantity", Quantity), new XAttribute("Part No", PartNo), new XAttribute("Description", Description), new XAttribute("Discount", Discount), new XAttribute("Freight", Freight), new XAttribute("Unit Value", UnitValue), new XAttribute("Line Total", LineTotal) ); xElement.Add(element); xElement.Save("");
Is it possible to make updates, or should we first delete the existing one and then re-add it with the new values?
source share