This documentation is archived and is not being maintained.

XmlElement.SetAttributeNode Method (XmlAttribute)

Adds the specified XmlAttribute.

Namespace: System.Xml
Assembly: System.Xml (in system.xml.dll)

public virtual XmlAttribute SetAttributeNode (
	XmlAttribute newAttr
)
public XmlAttribute SetAttributeNode (
	XmlAttribute newAttr
)
public function SetAttributeNode (
	newAttr : XmlAttribute
) : XmlAttribute
Not applicable.

Parameters

newAttr

The XmlAttribute node to add to the attribute collection for this element.

Return Value

If the attribute replaces an existing attribute with the same name, the old XmlAttribute is returned; otherwise, a null reference (Nothing in Visual Basic) is returned.

Exception typeCondition

ArgumentException

The newAttr was created from a different document than the one that created this node. Or this node is read-only.

InvalidOperationException

The newAttr is already an attribute of another XmlElement object. You must explicitly clone XmlAttribute nodes to re-use them in other XmlElement objects.

If an attribute with that name is already present in the element, it is replaced by the new one.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

XNA Framework

Supported in: 1.0
Show: