Get the namespace of element in CSharp

Description

The following code shows how to get the namespace of element.

Example


    //from  ww  w  .  j ava  2 s.c o m
using System;
using System.Linq;
using System.Xml.Linq;
using System.Collections;
using System.Collections.Generic;


public class MainClass{
   public static void Main(){
        XNamespace ns = "http://www.domain.com";
        XElement el2 = new XElement(ns + "Root", "content");
        Console.WriteLine(el2.Name.Namespace);
   }
}




















Home »
  C# Tutorial »
    XML »




Load Parse
Document
Element
Attribute
Namespace
Query
Save
Schema
Style