Body Class

Document Body.When the object is serialized out as xml, its qualified name is w:body.

Namespace:  DocumentFormat.OpenXml.Wordprocessing
Assembly:  DocumentFormat.OpenXml (in DocumentFormat.OpenXml.dll)

public class Body : BodyType

The following table lists the possible child types:

  • AltChunk <w:altChunk>

  • CustomXmlBlock <w:customXml>

  • SdtBlock <w:sdt>

  • Paragraph <w:p>

  • Table <w:tbl>

  • ProofError <w:proofErr>

  • PermStart <w:permStart>

  • PermEnd <w:permEnd>

  • BookmarkStart <w:bookmarkStart>

  • BookmarkEnd <w:bookmarkEnd>

  • CommentRangeStart <w:commentRangeStart>

  • CommentRangeEnd <w:commentRangeEnd>

  • MoveFromRangeStart <w:moveFromRangeStart>

  • MoveFromRangeEnd <w:moveFromRangeEnd>

  • MoveToRangeStart <w:moveToRangeStart>

  • MoveToRangeEnd <w:moveToRangeEnd>

  • CustomXmlInsRangeStart <w:customXmlInsRangeStart>

  • CustomXmlInsRangeEnd <w:customXmlInsRangeEnd>

  • CustomXmlDelRangeStart <w:customXmlDelRangeStart>

  • CustomXmlDelRangeEnd <w:customXmlDelRangeEnd>

  • CustomXmlMoveFromRangeStart <w:customXmlMoveFromRangeStart>

  • CustomXmlMoveFromRangeEnd <w:customXmlMoveFromRangeEnd>

  • CustomXmlMoveToRangeStart <w:customXmlMoveToRangeStart>

  • CustomXmlMoveToRangeEnd <w:customXmlMoveToRangeEnd>

  • DocumentFormat.OpenXml.Office2010.Word.CustomXmlConflictInsertionRangeStart <w14:customXmlConflictInsRangeStart>

  • DocumentFormat.OpenXml.Office2010.Word.CustomXmlConflictInsertionRangeEnd <w14:customXmlConflictInsRangeEnd>

  • DocumentFormat.OpenXml.Office2010.Word.CustomXmlConflictDeletionRangeStart <w14:customXmlConflictDelRangeStart>

  • DocumentFormat.OpenXml.Office2010.Word.CustomXmlConflictDeletionRangeEnd <w14:customXmlConflictDelRangeEnd>

  • InsertedRun <w:ins>

  • DeletedRun <w:del>

  • MoveFromRun <w:moveFrom>

  • MoveToRun <w:moveTo>

  • ContentPart <w:contentPart>

  • DocumentFormat.OpenXml.Office2010.Word.RunConflictInsertion <w14:conflictIns>

  • DocumentFormat.OpenXml.Office2010.Word.RunConflictDeletion <w14:conflictDel>

  • SectionProperties <w:sectPr>

[ISO/IEC 29500-1 1st Edition]

17.2.2 body (Document Body)

This element specifies the contents of the body of the document - the main document editing surface.

The document body contains what is referred to as block-level markup - markup which can exist as a sibling element to paragraphs in a WordprocessingML document.

[Example: Consider a document with a single paragraph in the main document story. This document would require the following WordprocessingML in its main document part:


The fact that the paragraph is inside the body element makes it part of the main document story. end example]

Parent Elements

document (§17.2.3)

Child Elements


altChunk (Anchor for Imported External Content)


bookmarkEnd (Bookmark End)


bookmarkStart (Bookmark Start)


commentRangeEnd (Comment Anchor Range End)


commentRangeStart (Comment Anchor Range Start)


customXml (Block-Level Custom XML Element)


customXmlDelRangeEnd (Custom XML Markup Deletion End)


customXmlDelRangeStart (Custom XML Markup Deletion Start)


customXmlInsRangeEnd (Custom XML Markup Insertion End)


customXmlInsRangeStart (Custom XML Markup Insertion Start)


customXmlMoveFromRangeEnd (Custom XML Markup Move Source End)


customXmlMoveFromRangeStart (Custom XML Markup Move Source Start)


customXmlMoveToRangeEnd (Custom XML Markup Move Destination Location End)


customXmlMoveToRangeStart (Custom XML Markup Move Destination Location Start)


del (Deleted Run Content)


ins (Inserted Run Content)


moveFrom (Move Source Run Content)


moveFromRangeEnd (Move Source Location Container - End)


moveFromRangeStart (Move Source Location Container - Start)


moveTo (Move Destination Run Content)


moveToRangeEnd (Move Destination Location Container - End)


moveToRangeStart (Move Destination Location Container - Start)


oMath (Office Math)


oMathPara (Office Math Paragraph)


p (Paragraph)


permEnd (Range Permission End)


permStart (Range Permission Start)


proofErr (Proofing Error Anchor)


sdt (Block-Level Structured Document Tag)


sectPr (Document Final Section Properties)


tbl (Table)


[Note: The W3C XML Schema definition of this element’s content model (CT_Body) is located in §A.1. end note]

© ISO/IEC29500: 2008.

The following code example creates a word-processing document by package and writes some text into it.

using System;
using System.IO.Packaging;
using DocumentFormat.OpenXml;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Wordprocessing;

namespace BodyEx
    class Program
        // Create a document by package, and write some text in it.
        static void Main(string[] args)
            string fileName = @"C:\users\public\documents\";

            // Create a word document by package. 
            Package package = Package.Open(fileName);
            WordprocessingDocument wordprocessingDocument = 
                WordprocessingDocument.Create(package, WordprocessingDocumentType.Template);

            // Make some changes to the document.
            MainDocumentPart mainDocumentPart = wordprocessingDocument.AddMainDocumentPart();
            mainDocumentPart.Document = new Document();
            Document document = mainDocumentPart.Document;
            Body body = document.AppendChild(new Body());
            Paragraph para = body.AppendChild(new Paragraph());
            Run run = para.AppendChild(new Run());
            run.AppendChild(new Text("Created text in body."));

            // Close the document and the package.

            Console.WriteLine("The package has been created.\nPress a key.");

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.