Share via


XDocument.GetNamedNodeProperty Method

InfoPath Developer Reference

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

Version Information
 Version Added:  InfoPath 2003

Syntax

expression.GetNamedNodeProperty(varMainDOMNode, bstrPropertyName, bstrDefaultValue)

expression   An expression that returns a XDocument object.

Parameters

Name Required/Optional Data Type Description
varMainDOMNode Required Variant An XML node corresponding to a nonattribute node in the main data source, for which a named property is to be set.
bstrPropertyName Required String Specifies the name of the property whose value is to be returned.
bstrDefaultValue Required String Specifies the default value to be returned if the property has not been set.

Return Value
String

Remarks

The GetNamedNodeProperty returns a string corresponding to the current value of the named property for the specified XML node in the main data source. If the specified property has not been set for this XML node, the specified default string is returned.

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 SetNamedNodeProperty method. Use the GetNamedNodeProperty method to read the value of a named property.

Security Level 2: Can be accessed only by forms running in the same domain as the currently open form, or by forms that have been granted cross-domain permissions.

Example

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

JScript
  var objXMLNode = XDocument.DOM.selectSingleNode("/items/item");

var strTest = XDocument.GetNamedNodeProperty(objXMLNode, 'cost', 'Value not set');

// The value of the "cost" named property is set to 100. XDocument.SetNamedNodeProperty(objXMLNode, 'cost', '100');

strTest = XDocument.GetNamedNodeProperty(objXMLNode, 'cost', 'Value not set');

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

JScript
  <xsl:value-of select="xdXDocument:GetNamedNodeProperty(item, 'cost', 'empty')"/>

See Also