[技術] XmlDocument與XDocument轉換 (Convert between XmlDocument and XDocument)

[技術] XmlDocument與XDocument轉換

1. 將XmlDocument轉成XDocument

   1: XmlDocument Xmldoc = new XmlDocument();
   2: XDocument XDoc = XDocument.Parse(Xmldoc.OuterXml);

 

2. 將XDocument轉成XmlDocument

   1: XDocument Xdoc = new XDocument();
   2: XmlDocument Xmldoc = new XmlDocument();
   3: Xmldoc.LoadXml(Xdoc.Document.ToString());