XNamespace.Get(String) Method

Definition

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

C#
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.

C#
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

Ürün Sürümler
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1
UWP 10.0

See also