Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
SetAttributeNode Method (XmlAttribute)
Collapse the table of content
Expand the table of content

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

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 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 .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

Community Additions

ADD
Show:
© 2015 Microsoft