Get default XNamespace of XElement in CSharp

Description

The following code shows how to get default XNamespace of XElement.

Example


  /* w  ww. j a  v a 2s . 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(){
        String xml = "<root xmlns='http://www.domain.com'/>";
        XElement e = XElement.Parse(xml);
        Console.WriteLine("Default namespace: {0}", e.GetDefaultNamespace());
   }
}




















Home »
  C# Tutorial »
    XML »




Load Parse
Document
Element
Attribute
Namespace
Query
Save
Schema
Style