_XDocument2.GetNamedNodeProperty(Object, String, String) 方法

定义

获取指定 XML 节点的命名属性的值,该节点必须是主数据源中的 nonattribute 节点。

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

参数

varMainDOMNode
Object

与主数据源中的 nonattribute 节点相对应的 XML 节点,将为该节点返回命名属性。

bstrPropertyName
String

指定将返回其值的属性名称。

bstrDefaultValue
String

指定当尚未设置该属性时要返回的默认值。

返回

指定的 XML 节点的命名属性,该节点必须是主数据源中的 nonattribute 节点。

示例

以下示例演示 XML 节点(称为“item”)的命名属性(名为“cost”)值的设置和获取:

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");

在以下 XSL 示例中,将显示 item 节点的命名属性“cost”:

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

以下示例演示 XML 节点(称为“item”)的命名属性(名为“cost”)值的设置和获取:

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");

在以下 XSL 示例中,将显示 item 节点的命名属性“cost”:

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

注解

命名属性允许用户将字符串与主数据源中 XML 元素节点的用户定义的属性相关联。 可以使用 方法设置 SetNamedNodeProperty(IXMLDOMNode, String, String) 命名属性的值 使用 GetNamedNodeProperty 方法读取命名属性的值。

重要提示:此成员只能由与当前打开的窗体在同一域中运行的表单访问,或者由已授予跨域权限的表单访问。

适用于