Create an XElement from tag name and inner XElement content in CSharp

Description

The following code shows how to create an XElement from tag name and inner XElement content.

Example


    //from  w  w w  . j  a  va 2s. c o  m
using System;
using System.Linq;
using System.Xml.Linq;


public class MainClass{
   public static void Main(){
        XElement root;

        root = new XElement("Root", new XElement("NewChild", "n"));
        Console.WriteLine(root);
        
    }
}




















Home »
  C# Tutorial »
    XML »




Load Parse
Document
Element
Attribute
Namespace
Query
Save
Schema
Style