Addition Operator
Collapse the table of content
Expand the table of content

XNamespace.Addition Operator

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Combines an XNamespace object with a local name to create an XName.

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

'Declaration
Public Shared Operator + ( _
	ns As XNamespace, _
	localName As String _
) As XName

Parameters

ns
Type: System.Xml.Linq.XNamespace
An XNamespace that contains the namespace.
localName
Type: System.String
A String that contains the local name.

Return Value

Type: System.Xml.Linq.XName
The new XName constructed from the namespace and local name.

This operator enables the common idiom of combining a namespace and a local name in the construction of an element or attribute. This idiom provides some of the benefits of having namespace prefixes, in that you can refer to a namespace using a variable that is short. This eliminates syntactic noise in the code that creates XML trees.

The following example shows the use of the + operator to create an XName from an XNamespace and a local name.


Dim output As New StringBuilder
Dim aw As XNamespace = "http://www.adventure-works.com"
Dim root As XElement = New XElement(aw + "Root", _
    New XElement(aw + "Child") _
)
output.Append(root)
output.Append(Environment.NewLine)

OutputTextBlock.Text = output.ToString()


Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2017 Microsoft