Create XElement with XML structure similar structure


using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;

class Program
{
    static void Main()
    {
        XElement customer =
        new XElement("customer",
                new XAttribute("id", 123),
                new XElement("firstname", "Jack"),
                new XElement("lastname", "Smith", new XComment("It is a name")
        )
        );
        Console.WriteLine(customer);
    }
}

The output:

JackSmith
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.