XName.Get Method


The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Gets an XName object.

Namespace:   System.Xml.Linq
Assembly:  System.Xml.Linq (in System.Xml.Linq.dll)


Gets an XName object from an expanded name.

System_CAPS_pubmethodSystem_CAPS_staticGet(String, String)

Gets an XName object from a local name and a namespace.

This method provides overloads that allow you to create an XName from a expanded XML name. You can create an XName from a string in the form {namespace}localname, or from a namespace and a local name, specified separately.

A much more common and easier way to create an XName is to use the implicit conversion from string. To create a name that is in a namespace, the common approach is to use the addition operator overload that allows you to combine an XNamespace object and a string.

For more information and examples, see How to: Create a Document with Namespaces (C#) (LINQ to XML)1.

For more information on using namespaces in Visual Basic, see Namespaces in Visual Basic (LINQ to XML)1.

Because XName objects are atomized, if there is an existing XName with exactly the same name, the assigned variable will refer to the existing XName. If there is no existing XName, a new one will be created and initialized.

Return to top