If you have an XmlDocument and you want’t to query it with linq, you first have to convert the XmlDocument to an XDocument:

// Convert XmlDocument to XDocument
XmlDocument xmlDocument = new XmlDocument();
xmlDocument.Load(@"C:\Temp\Test.xml");
XDocument xDocument = XDocument.Parse(xmlDocument.OuterXml);


// Convert XDocument to XmlDocument
xmlDocument.LoadXml(xDocument.ToString());

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.