Mega Code Archive

 
Categories / C# / XML LINQ
 

XElement GetNamespaceOfPrefix gets the namespace associated with a particular prefix for this XElement

using System; using System.Linq; using System.Xml.Linq; using System.Collections; using System.Collections.Generic; public class MainClass{    public static void Main(){         XElement xmlTree = XElement.Parse("<Root xmlns:aw='http://www.domain.com'/>");         XNamespace awNamespace = xmlTree.GetNamespaceOfPrefix("aw");         Console.WriteLine("Namespace: {0}", awNamespace);    } }