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.11
public override string GetText()

Return Value

Type: String

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

Finds and outputs all paragraphs in a document that are bulleted or numbered.
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}",
Shows the difference between calling the GetText and ToString methods on a node.
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