using System;
using System.Xml;
using System.Xml.Linq;
namespace ACCode
{
class Program
{
static void Main(string[] args)
{
var xmlDocumentobj = new XmlDocument();
xmlDocumentobj.LoadXml("<Root><User1>Test</User1></Root>");
var xDocument = ConvertToXDocument(xmlDocumentobj);
Console.ReadLine();
}
// Method to convert the XmlDocument to XDocument
public static XDocument ConvertToXDocument( XmlDocument input)
{
using (var reader = new XmlNodeReader(input))
{
reader.MoveToContent();
return XDocument.Load(reader);
}
}
}
}