I am a .net beginner. I need to add some data to xml file
the xml file is:
--- 1st level /* i dont want to create this because this
Assuming you have the original document:
var doc = XDocument.Load(...);
then create a new element (not a document)
//XDocument doc = new XDocument(
// new XElement("stock", /* how to go inside existing "stock"? */
var newElement = new XElement("items",
new XElement("productname", "Toothpaste"),
new XElement("brandname", "CloseUp"),
new XElement("quantity","16"),
new XElement("price","15"));
And then insert it:
doc.Element("stock").Add(newElement);
doc.Save(....);