Udostępnij za pośrednictwem


Właściwość XMLNode.NodeText —

Pobiera lub ustawia wartość tekstu XMLNode kontroli.

Przestrzeń nazw:  Microsoft.Office.Tools.Word
Zestaw:  Microsoft.Office.Tools.Word (w Microsoft.Office.Tools.Word.dll)

Składnia

'Deklaracja
Property NodeText As String
string NodeText { get; set; }

Wartość właściwości

Typ: System.String
Wartość tekstową z XMLNode kontroli.

Uwagi

Ustawienie wartości tekstu nie usuwa istniejące zakładki wewnątrz XMLNode kontroli.

Przykłady

Następujący kod w przykładzie wykorzystano NodeType właściwość w celu określenia czy XMLNode jest węzeł element lub atrybut.Jeśli XMLNode jest elementem, w przykładzie wykorzystano NodeText właściwość, aby ustawić tekst w elemencie.Jeśli XMLNode jest atrybutem, w przykładzie wykorzystano NodeValue właściwość, aby ustawić wartość atrybutu.W tym przykładzie założono, że bieżący dokument zawiera XMLNode o nazwie 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 + "'.");
    }
}

Zabezpieczenia programu .NET Framework

Zobacz też

Informacje

XMLNode Interfejs

Przestrzeń nazw Microsoft.Office.Tools.Word