_XDocument4.GetNamedNodeProperty(Object, String, String) Method

Definition

Gets the value of a named property for the specified XML node, which must be a nonattribute node in the main data source.

public:
 System::String ^ GetNamedNodeProperty(System::Object ^ varMainDOMNode, System::String ^ bstrPropertyName, System::String ^ bstrDefaultValue);
public string GetNamedNodeProperty (object varMainDOMNode, string bstrPropertyName, string bstrDefaultValue);
abstract member GetNamedNodeProperty : obj * string * string -> string
Public Function GetNamedNodeProperty (varMainDOMNode As Object, bstrPropertyName As String, bstrDefaultValue As String) As String

Parameters

varMainDOMNode
Object

An XML node corresponding to a nonattribute node in the main data source, for which a named property is to be returned.

bstrPropertyName
String

Specifies the name of the property whose value is to be returned.

bstrDefaultValue
String

Specifies the default value to be returned if the property has not been set.

Returns

The named property for the specified XML node, which must be a nonattribute node in the main data source.

Implements

Examples

The following example demonstrates setting and getting the value of a named property (with the name "cost") of an XML node (called "item"):

IXMLDOMNode item = thisXDocument.DOM.selectSingleNode(@"/items/item");
string test = thisXDocument.<span class="label">GetNamedNodeProperty</span>(item, 'cost', 'Value not set');
// The value of the "cost" named property is set to 100.
thisXDocument.SetNamedNodeProperty(item, "cost", "100");
test = thisXDocument.GetNamedNodeProperty(item, "cost", "Value not set");

In the following XSL example, the "cost" named property of the item node is displayed:

&lt;xsl:value-of select="xdXDocument:<span class="label">GetNamedNodeProperty</span>(item, 'cost', 'empty')"/&gt;

The following example demonstrates setting and getting the value of a named property (with the name "cost") of an XML node (called "item"):

IXMLDOMNode item = thisXDocument.DOM.selectSingleNode(@"/items/item");
string test = thisXDocument.<span class="label">GetNamedNodeProperty</span>(item, 'cost', 'Value not set');
// The value of the "cost" named property is set to 100.
thisXDocument.SetNamedNodeProperty(item, "cost", "100");
test = thisXDocument.GetNamedNodeProperty(item, "cost", "Value not set");

In the following XSL example, the "cost" named property of the item node is displayed:

&lt;xsl:value-of select="xdXDocument:<span class="label">GetNamedNodeProperty</span>(item, 'cost', 'empty')"/&gt;

Remarks

Named properties allow users to associate strings with user-defined properties of XML element nodes in the main data source. The value of a named property can be set by using the Microsoft.Office.Interop.InfoPath._XDocument4.SetNamedNodeProperty(Microsoft.Office.Interop.InfoPath.IXMLDOMNode,System.String,System.String) method. Use the GetNamedNodeProperty method to read the value of a named property.

Applies to