Share via


XMLNode.NodeValue Property (2007 System)

Gets or sets the value of an XMLNode that represents an attribute.

Namespace:  Microsoft.Office.Tools.Word
Assembly:  Microsoft.Office.Tools.Word.v9.0 (in Microsoft.Office.Tools.Word.v9.0.dll)

Syntax

'Declaration
<BrowsableAttribute(False)> _
Public Property NodeValue As String
'Usage
Dim instance As XMLNode 
Dim value As String 

value = instance.NodeValue

instance.NodeValue = value
[BrowsableAttribute(false)]
public string NodeValue { get; set; }
[BrowsableAttribute(false)]
public:
property String^ NodeValue {
    String^ get ();
    void set (String^ value);
}
public function get NodeValue () : String 
public function set NodeValue (value : String)

Property Value

Type: System.String
The value of the XMLNode that represents an attribute.

Remarks

Use the NodeType property to determine which type of node you are working with.

For XMLNode controls with a NodeType value of wdXMLNodeElement, the NodeValue property returns nothing.

Examples

The following code example uses the NodeType property to determine whether an XMLNode is an element or attribute node. If the XMLNode is an element, the example uses the NodeText property to set the text in the element. If the XMLNode is an attribute, the example uses the NodeValue property to set the attribute value. This example assumes that the current document contains an XMLNode named CustomerLastNameNode.

Private Sub DisplayNodeDetails()
    If Me.CustomerLastNameNode.NodeType = _
        Word.WdXMLNodeType.wdXMLNodeElement Then 
        Me.CustomerLastNameNode.NodeText = "Smith"
        MsgBox("The element '" & Me.CustomerLastNameNode.BaseName & _
            "' has the text '" & Me.CustomerLastNameNode.NodeText & "'.")

    ElseIf Me.CustomerLastNameNode.NodeType = _
        Word.WdXMLNodeType.wdXMLNodeAttribute Then 
        Me.CustomerLastNameNode.NodeValue = "Smith"
        MsgBox("The attribute '" & Me.CustomerLastNameNode.BaseName & _
            "' has the value '" & Me.CustomerLastNameNode.NodeValue & "'.")
    End If 
End Sub
private void DisplayNodeDetails()
{
    if (this.CustomerLastNameNode.NodeType ==
        Word.WdXMLNodeType.wdXMLNodeElement)
    {
        this.CustomerLastNameNode.NodeText = "Smith";
        MessageBox.Show("The element '" +
            this.CustomerLastNameNode.BaseName + "' has the text '" + 
            this.CustomerLastNameNode.NodeText + "'.");
    }

    else if (this.CustomerLastNameNode.NodeType ==
        Word.WdXMLNodeType.wdXMLNodeAttribute)
    {
        this.CustomerLastNameNode.NodeValue = "Smith";
        MessageBox.Show("The attribute '" +
            this.CustomerLastNameNode.BaseName + "' has the value '" + 
           this.CustomerLastNameNode.NodeValue + "'.");
    }
}

.NET Framework Security

See Also

Reference

XMLNode Class

XMLNode Members

Microsoft.Office.Tools.Word Namespace