Namespace Construction : Namespace « XML LINQ « C# / CSharp Tutorial






using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Xml.Linq;

    public class MainClass
    {
        public static void Main()
        {
            XNamespace ns = "A";
            XElement root = new XElement(ns + "employee",
                                new XElement(ns + "firstname","aaa"),
                                new XElement(ns + "lastname","bbb")
                                );
            root.SetAttributeValue("xmlns", ns);
            //root.SetAttributeValue(XNamespace.Xmlns + "your value", ns);
            Console.WriteLine(root.ToString());
        }
    }








31.5.Namespace
31.5.1.Namespace Construction
31.5.2.Read Namespace from XElement