LINQ to XML - Load XML fragments from file

后端 未结 3 945
伪装坚强ぢ
伪装坚强ぢ 2020-12-03 11:04

I have source XMLfiles that come in with multiple root elements and there is nothing I can do about it. What would be the best way to load these fragments into an XDocument

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-03 11:54

    roughly, something like.

    var newXML= new XElement("products",
                   from x in Xdocuments.parse(originalFile).descendants("product")                       
                   select new XElement("product",x.value)
                );
    

提交回复
热议问题