XAttribute Constructor (XAttribute)
Collapse the table of content
Expand the table of content

XAttribute Constructor (XAttribute)

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

Initializes a new instance of the XAttribute class from another XAttribute object.

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

'Declaration
Public Sub New ( _
	other As XAttribute _
)

Parameters

other
Type: System.Xml.Linq.XAttribute
An XAttribute object to copy from.

ExceptionCondition
ArgumentNullException

The other parameter is Nothing.

This constructor is primarily used internally when making a deep copy of an XML tree.

This example demonstrates that creating a deep copy of an XML tree creates a copy, not a clone, of an attribute in the tree.


Dim output As New StringBuilder
Dim root1 As XElement = <Root Att1='abc'/>
' Make a deep copy.
Dim root2 As XElement = New XElement(root1)
If root1.Attribute("Att1") Is root2.Attribute("Att1") Then
    output.Append("This will not be printed")
    output.Append(Environment.NewLine)
Else
    output.Append("Creating a deep copy created a new attribute from the original.")
    output.Append(Environment.NewLine)
End If

OutputTextBlock.Text = output.ToString()


Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2017 Microsoft