This document is archived and information here might be outdated.  Recommended version.


IXmlPropertySet.SetAttribute Method (ArcObjects .NET 10.4 SDK)
ArcObjects Library Reference (GeoDatabase)  

IXmlPropertySet.SetAttribute Method

Sets the attribute of the specified element.

[Visual Basic .NET]
Public Sub SetAttribute ( _
    ByVal Name As String, _
    ByVal Attribute As String, _
    ByVal Value As Object, _
    ByVal action As esriXmlSetPropertyAction _
)
[C#]
public void SetAttribute (
    string Name,
    string Attribute,
    object Value,
    esriXmlSetPropertyAction action
);
[C++]
HRESULT SetAttribute(
  BSTR Name,
  BSTR Attribute,
  VARIANT Value,
  esriXmlSetPropertyAction action
);
[C++]

Parameters Name [in] Name is a parameter of type BSTR Attribute [in] Attribute is a parameter of type BSTR Value [in] Value is a parameter of type VARIANT action [in]
action is a parameter of type esriXmlSetPropertyAction

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Remarks

The SetAttribute method adds or replaces XML attributes and sets the attribute value. 

If the Name expression defines repeating elements, the SetAttribute method will change all elements that satisfy the XPath pattern. For instance "idinfo/keywords/theme/themekey" locates all theme keywords. For more information on XPath, see the IXmlPropertySet interface.

The Action parameter is a esriXmlSetPropertyAction constant. These constants allow several options when encountering different scenarios in metadata. Possible scenarios range from metadata elements which already exist and have attribute value to non-existent metadata elements. How to handle the different cases is determined by the Action parameter.  The esriXmlSetPropertyAction constants work differently depending on the presence/absence of the XML element as well as the presence/absence of the attribute. It is important to be familiar with the different actions. For instance, if the Name expression fails to located the specified XML element, all esriXmlSetPropertyAction constants, except "Replace If Exist", will Add the XML element, attribute, and attribute value. The table below better explains the action constants:

Action Constant Element and Attribute Exist Element exists, Attribute does not Element does not exist
esriXSPAAddOrReplace Replaces attribute value Adds attribute and value Adds element, attribute and value
esriXSPAAddIfNotExists Nothing happens Nothing happens Adds element, attribute and value
esriXSPAReplaceIfExists Replaces attribute value Adds attribute and value Nothing happens
esriXSPAAddDuplicate Adds additional element, attribute and value Adds additional element, attribute and value Adds element, attribute and value

See Also

IXmlPropertySet Interface | esriXmlSetPropertyAction Constants