Mega Code Archive

 
Categories / C# / XML LINQ
 

XDocument Parse (String) parses a string to create a new XDocument

using System; using System.IO; using System.Linq; using System.Xml.Linq; using System.Xml; using System.Collections; using System.Collections.Generic; public class MainClass {     public static void Main()     {         string str = @"<?xml version=""1.0""?>         <!-- comment at the root level -->         <Root>             <Child>Content</Child>         </Root>";         XDocument doc = XDocument.Parse(str);         Console.WriteLine(doc);     } }