Add XElement to XElement in CSharp

Description

The following code shows how to add XElement to XElement.

Example


/* w  w  w .j  av a  2 s.  c o m*/
using System;
using System.Linq;
using System.Xml.Linq;


public class MainClass
{
    public static void Main()
    {
        XElement src = new XElement("Root",
                           new XElement("Child1", 1),
                           new XElement("Child2", 2),
                           new XElement("Child3", 3)
                       );

        src.Add(new XElement("Child4", 4));
        Console.WriteLine(src);
    }
}




















Home »
  C# Tutorial »
    XML »




Load Parse
Document
Element
Attribute
Namespace
Query
Save
Schema
Style