Load an XElement from a TextReader in CSharp
Description
The following code shows how to load an XElement from a TextReader.
Example
using System;// www . ja v a 2 s . c o m
using System.IO;
using System.Linq;
using System.Xml.Linq;
using System.Collections;
using System.Collections.Generic;
public class MainClass
{
public static void Main()
{
TextReader sr = new StringReader("<Root><Child/></Root>");
XElement xmlTree = XElement.Load(sr);
sr.Close();
Console.WriteLine(xmlTree);
}
}
The code above generates the following result.