CompositeNodeGetText Method
Gets the text of this node and of all its children.

Namespace: Aspose.Words
Assembly: Aspose.Words (in Aspose.Words.dll) Version: 19.9
Syntax
public override string GetText()

Return Value

Type: String
Remarks

The returned string includes all control and special characters as described in ControlChar.

Examples
Finds and outputs all paragraphs in a document that are bulleted or numbered.
[C#]

NodeCollection paras = doc.GetChildNodes(NodeType.Paragraph, true);
foreach (Paragraph para in paras.OfType<Paragraph>())
{
    if (para.ListFormat.IsListItem)
    {
        Console.WriteLine(String.Format("*** A paragraph belongs to list {0}",
            para.ListFormat.List.ListId));
        Console.WriteLine(para.GetText());
    }
}
Examples
Shows the difference between calling the GetText and ToString methods on a node.
[C#]

Document doc = new Document();

// Enter a dummy field into the document.
DocumentBuilder builder = new DocumentBuilder(doc);
builder.InsertField("MERGEFIELD Field");

// GetText will retrieve all field codes and special characters
Console.WriteLine("GetText() Result: " + doc.GetText());

// ToString will export the node to the specified format. When converted to text it will not retrieve fields code 
// or special characters, but will still contain some natural formatting characters such as paragraph markers etc. 
// This is the same as "viewing" the document as if it was opened in a text editor.
Console.WriteLine("ToString() Result: " + doc.ToString(SaveFormat.Text));
See Also