If you do not want to suffer with all the features of the XML-DOM, then try using LiNQtoXML. The namespace is System.Xml.Linq , the main working class is XElement .
Downloading the original xml:
var myDoc = XElement.Load("myFile.xml");
You can also use the static XElement.Parse(string) method if the source is a string.
We are looking for the desired item:
var element = myDoc.Descendants("elementName").FirstOrDefault();
We read and write the value of the element:
var elValue = element?.Value; element.Value = "newValue";//элемент должен существовать
We read and write the attribute:
var attrValue = element?.Attribute("attrName")?.Value; element.Attribute("attrName").Value = "newAttrValue";
Add a nested element with a text value and an attribute
element.Add(new XElement("subElement", "value", new XAttribute("attrName","AttrValue"));
Save the result to disk
myDoc.Save("fileName")
As you can see everything is quite transparent and clear. XMLtoLiNQ fully supports the classic XML-DOM, but does it more elegantly than the older approach implemented in XmlDocument and related classes.
The link documentation below contains examples in sufficient quantity to understand and links to the description of the accompanying classes.
XDocument class
XElement class