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);

Leave a Reply

Your email address will not be published. Required fields are marked *

Liked this content?. Please spread the word :)

  • RSS
  • Twitter
    Visit Us
    Follow Me