XNamespace.Get(String) Method

Definition

Gets an XNamespace for the specified Uniform Resource Identifier (URI).

public static System.Xml.Linq.XNamespace Get (string namespaceName);

Parameters

namespaceName
String

A String that contains a namespace URI.

Returns

An XNamespace created from the specified URI.

Examples

The following example gets a XNamespace from a specified URI.

XNamespace aw = XNamespace.Get("http://www.adventure-works.com");

// This is the preferred form.
XNamespace aw2 = "http://www.adventure-works.com";
Console.WriteLine(aw);
Console.WriteLine(aw2);

This example produces the following output:

http://www.adventure-works.com
http://www.adventure-works.com

Remarks

The returned XNamespace object is guaranteed to be atomic (that is, it is the only one in the system for that particular URI).

Applies to

See also