Adding child nodes using c# Xdocument class

后端 未结 2 1772
我在风中等你
我在风中等你 2021-01-11 13:45

I have an xml file as given below.


 

  

         


        
2条回答
  •  萌比男神i
    2021-01-11 14:02

        Document.Root.Element("Characters").Add(new XElement("Character", new XAttribute("ID", "File0"), new XElement("Value", "value0"), new XElement("Description")),
            new XElement("Character", new XAttribute("ID", "File1"), new XElement("Value", "value1"), new XElement("Description")));
    

    Note: I have not included the namespace for brevity. You have to add those.

提交回复
热议问题