_XDocument2.GetNamedNodeProperty 方法

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

命名空间:  Microsoft.Office.Interop.InfoPath.SemiTrust
程序集:  Microsoft.Office.Interop.InfoPath.SemiTrust(位于 Microsoft.Office.Interop.InfoPath.SemiTrust.dll 中)

语法

声明
Function GetNamedNodeProperty ( _
    varMainDOMNode As Object, _
    bstrPropertyName As String, _
    bstrDefaultValue As String _
) As String
用法
Dim instance As _XDocument2
Dim varMainDOMNode As Object
Dim bstrPropertyName As String
Dim bstrDefaultValue As String
Dim returnValue As String

returnValue = instance.GetNamedNodeProperty(varMainDOMNode, _
    bstrPropertyName, bstrDefaultValue)
string GetNamedNodeProperty(
    Object varMainDOMNode,
    string bstrPropertyName,
    string bstrDefaultValue
)

参数

  • varMainDOMNode
    类型:System.Object

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

  • bstrPropertyName
    类型:System.String

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

  • bstrDefaultValue
    类型:System.String

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

返回值

类型:System.String
指定 XML 节点的命名属性,该节点必须是主数据源中的 nonattribute 节点。

备注

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

重要

此成员只能由与当前打开的表单在相同域中运行的表单访问,或者由已授予跨域权限的表单访问。

示例

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

IXMLDOMNode item = thisXDocument.DOM.selectSingleNode(@"/items/item");
string test = thisXDocument.GetNamedNodeProperty(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":

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

另请参阅

引用

_XDocument2 接口

_XDocument2 成员

Microsoft.Office.Interop.InfoPath.SemiTrust 命名空间