SectionBody Property

Returns the Body child node of the section.

Namespace:  Aspose.Words
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.10.0


public Body Body { get; }

Property Value

Type: Body


Body contains main text of the section.

Returns null if the section does not have a Body node among its children.


Clears main text from all sections from the document leaving the sections themselves.
// Open a document
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

builder.Write("Section 1");
builder.Write("Section 2");

// This shows what is in the document originally
// The document has two sections
Assert.AreEqual($"Section 1{ControlChar.SectionBreak}Section 2{ControlChar.SectionBreak}", doc.GetText());

// Loop through all sections in the document
foreach (Section section in doc.Sections.OfType<Section>())
    // Each section has a Body node that contains main story (main text) of the section
    Body body = section.Body;

    // This clears all nodes from the body

    // Technically speaking, for the main story of a section to be valid, it needs to have
    // at least one empty paragraph. That's what the EnsureMinimum method does

// Check how the content of the document looks now
Assert.AreEqual($"{ControlChar.SectionBreak}{ControlChar.SectionBreak}", doc.GetText());

ExpandedSee Also