Change XML root element name

后端 未结 5 768
星月不相逢
星月不相逢 2021-01-12 02:40

I have XML stored in string variable:

xxx000Defaul         


        
5条回答
  •  失恋的感觉
    2021-01-12 03:17

    You can use LINQ to XML to parse the XML string, create a new root and add the child elements and attributes of the original root to the new root:

    XDocument doc = XDocument.Parse("...");
    
    XDocument result = new XDocument(
        new XElement("Masterlist", doc.Root.Attributes(), doc.Root.Nodes()));
    

提交回复
热议问题