w:document (Root Document Element)
Root element of the WordprocessingML main document part (document.xml).
Child elements
Description
w:document is the root element of the main document part (word/document.xml) in an Office Open XML WordprocessingML package. It is defined in ECMA-376 Part 1 §17.2.3.
The element must contain exactly one w:body child, which holds all of the document’s content. The mc:Ignorable attribute (Markup Compatibility) lists namespace prefixes whose elements should be ignored by processors that do not understand them.
Attributes
| Attribute | Type | Possible Values | Description |
|---|---|---|---|
mc:Ignorable |
xsd:string |
Space-separated list of namespace prefixes (e.g. "w14 w15 w16se"). |
Prefixes of elements/attributes that non-understanding processors should ignore. |
w:conformance |
ST_ConformanceClass |
strict, transitional |
Declares the conformance class of the document against the OOXML schema. |
Examples
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<w:document xmlns:wpc="..." xmlns:w="..." mc:Ignorable="w14 w15">
<w:body>
<w:p><w:r><w:t>Hello World</w:t></w:r></w:p>
<w:sectPr/>
</w:body>
</w:document>
using (var doc = WordprocessingDocument.Create(stream, WordprocessingDocumentType.Document))
{
var mainPart = doc.AddMainDocumentPart();
mainPart.Document = new Document(
new Body(
new Paragraph(
new Run(
new Text("Hello World"))),
new SectionProperties()));
}