ReplaceAttributes Method (Object)
Collapse the table of content
Expand the table of content

XElement.ReplaceAttributes Method (Object)

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

Replaces the attributes of this element with the specified content.

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

'Declaration
Public Sub ReplaceAttributes ( _
	content As Object _
)

Parameters

content
Type: System.Object
The content that will replace the attributes of this element.

This method first removes existing attributes. It then adds the specified content.

For more information about the valid content that can be passed to this function, see Valid Content of XElement and XDocument Objects in the .NET Framework documentation.

This method will raise the Changed and the Changing events.

The following example creates an element with three attributes. It then uses this method to replace all of the attributes of the element with a single attribute.


Dim output As New StringBuilder
Dim root As XElement = <Root Att1="1" Att2="2" Att3="3"/>
root.ReplaceAttributes(New XAttribute("NewAtt1", 101))
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