XElement.ReplaceAttributes Method (array<Object[])

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Replaces the attributes of this element with the specified content.

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

Syntax

'Declaration
Public Sub ReplaceAttributes ( _
    ParamArray content As Object() _
)
public void ReplaceAttributes(
    params Object[] content
)

Parameters

  • content
    Type: array<System.Object[]
    A parameter list of content objects.

Remarks

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.

Examples

The following example creates an element with three attributes. It then replaces the attributes with other attributes.

XElement root = new XElement("Root",
    new XAttribute("Att1", 1),
    new XAttribute("Att2", 2),
    new XAttribute("Att3", 3)
);
root.ReplaceAttributes(
    new XAttribute("NewAtt1", 101),
    new XAttribute("NewAtt2", 102),
    new XAttribute("NewAtt3", 103)
);
Dim root As XElement = <Root Att1="1" Att2="2" Att3="3"/>
root.ReplaceAttributes( _
New XAttribute("NewAtt1", 101), _
New XAttribute("NewAtt2", 102), _
New XAttribute("NewAtt3", 103))

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.