다음을 통해 공유


XMLNode.Text Property

Definition

Gets or sets the plain unformatted text of the XMLNode control.

public:
 property System::String ^ Text { System::String ^ get(); void set(System::String ^ value); };
public string Text { get; set; }
member this.Text : string with get, set
Public Property Text As String

Property Value

The plain unformatted text of the XMLNode control.

Examples

The following code example displays the number of child nodes in an XMLNode, replaces the text inside the XMLNode by using the Text property, and then displays the number of child nodes again. After setting the Text property, the number of child nodes is zero. This example assumes that the current document contains an XMLNode named CustomerNode.

private void SetTextInParentNode()
{
    MessageBox.Show("'" + this.CustomerNode.BaseName + "' has " +
        this.CustomerNode.ChildNodes.Count + " child nodes.");

    this.CustomerNode.Text = "Jones";

    MessageBox.Show("'" + this.CustomerNode.BaseName + "' now has " +
        this.CustomerNode.ChildNodes.Count + " child nodes.");
}
Private Sub SetTextInParentNode()
    MsgBox("'" & Me.CustomerNode.BaseName & "' has " & _
        Me.CustomerNode.ChildNodes.Count & " child nodes.")
    Me.CustomerNode.Text = "Jones"
    MsgBox("'" & Me.CustomerNode.BaseName & "' now has " _
        & Me.CustomerNode.ChildNodes.Count & " child nodes.")
End Sub

Remarks

Setting this property replaces all of the text inside the XMLNode, including any child nodes.

This property is read-only during design time. It can only be set during run time.

Applies to