How to populate XDocument from a String in C# ?


This content was proof-read by Grammarly. You can Try Grammary for FREE

Want to load or populate XDocument from a string in C# ? . Use the Parse method defined in the XDocument class as demonstrated below.

How to populate XDocument from a String in C# ?

using System;
using System.Xml.Linq;

namespace ACCode
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = "<Root>AC Code Input</Root>";
            XDocument xdocument = XDocument.Parse(input);
            Console.WriteLine(xdocument);
            Console.ReadLine();
        }
    }
}
Newsletter Signup

Subscribe to our weekly newsletter below and never miss the latest product or an exclusive offer.

Newsletter Signup

Subscribe to our weekly newsletter below and never miss the latest product or an exclusive offer.

%d bloggers like this: