Export (0) Print
Expand All

XName.Get Method

Gets an XName object.

This member is overloaded. For complete information about this member, including syntax, usage, and examples, click a name in the overload list.

  NameDescription
Public method Static member Get(String) Gets an XName object from an expanded name.
Public method Static member Get(String, String) Gets an XName object from a local name and a namespace.
Top

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).

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

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.

Community Additions

ADD
Show:
© 2014 Microsoft