Use XElement.Parse to parse an element document

image_pdfimage_print
   
 
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Linq;
using System.Reflection;
using System.Xml.Linq;

class Program {
    static void Main(string[] args) {
        string doc = @"<people>
                          <!-- Employee section -->
                          <person>
                            <id>1</id>
                            <firstname>C</firstname>
                            <lastname>L</lastname>
                            <idrole>1</idrole>
                          </person>
                           </people>";
        XElement xml = XElement.Parse(doc);
        Console.WriteLine(xml);
    }
}

    


This entry was posted in XML LINQ. Bookmark the permalink.