Create an XElement from tag name and string content in CSharp

Description

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

Example


    /*from  w  ww.  j  a  v a  2 s  . 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", "Some text");
        Console.WriteLine(root);
        
    }
}




















Home »
  C# Tutorial »
    XML »




Load Parse
Document
Element
Attribute
Namespace
Query
Save
Schema
Style