Create Namespace in CSharp

Description

The following code shows how to create Namespace.

Example


    /*from w  ww  . j a va  2s .c om*/
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());
        }
    }




















Home »
  C# Tutorial »
    XML »




Load Parse
Document
Element
Attribute
Namespace
Query
Save
Schema
Style