Copying part of an xml document to another document using Xdocument

后端 未结 2 1956
谎友^
谎友^ 2020-12-20 10:36

I have an xml document which is roughly as follows


    
        
2条回答
  •  不知归路
    2020-12-20 11:10

    Read in the input XML into one XDocument and construct a second, passing in the node you are interested in:

    XDocument newDoc = new XDocument(XDocument.Load("input.xml").Descendants("Body").First());
    

提交回复
热议问题