I am new to LINQ to XML. After you have built XDocument
, how do you get the OuterXml
of it like you did with XmlDocument
?
You only need to use the overridden ToString() method of the object:
XDocument xmlDoc ...
string xml = xmlDoc.ToString();
This works with all XObjects, like XElement, etc.