Created
October 24, 2016 09:40
-
-
Save bozhink/b0ffa979bfacda481bf1c23302fcfdb0 to your computer and use it in GitHub Desktop.
Extension method to transform XDocument to XmlDocument
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Converts XDocument to XmlDocument. | |
/// Original source: <see cref="http://stackoverflow.com/questions/1508572/converting-xdocument-to-xmldocument-and-vice-versa"/> | |
/// </summary> | |
/// <param name="document">XDocument instance to be converted.</param> | |
/// <returns></returns> | |
public static XmlDocument XToXmlDocument(this XDocument document) | |
{ | |
XmlDocument xmlDocument = new XmlDocument(); | |
using (XmlReader xmlReader = document.CreateReader()) | |
{ | |
xmlDocument.Load(xmlReader); | |
} | |
return xmlDocument; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment