XML format
OOXML document
The body of a .docx, inside the zip. Text lives in w:t runs, so extracting it means walking runs rather than reading element text.
A .docx is a zip, and word/document.xml is the part that holds the content. Anyone who has tried to read one has met the same surprise: a sentence is not a string. Word splits text into <w:r> runs at every formatting boundary, every spell-check mark and every revision, so "the quick brown fox" may be five runs, and a naive text extraction returns it in pieces or loses the spaces between them.
The other half of the surprise is that the document is not self-contained. Images, hyperlink targets, headers and footnotes live in sibling parts and are referenced by relationship ID through word/_rels/document.xml.rels, so a document part read on its own has dangling references by design.
- Text is in <w:t>, not in element content generally. Concatenate runs in document order; a run boundary is not a word boundary.
- A <w:t> with leading or trailing spaces needs xml:space="preserve", or the space is lost on rewrite.
- r:id attributes point into the relationships part, not into this document. Resolving them needs the .rels file from the same zip.
- [Content_Types].xml must declare every part's media type, and it is the one part that is not addressable as a relationship.
- Element order within a paragraph is significant: <w:pPr> must precede the runs it applies to.
- Root element
<document>- Media type
application/xml- Extensions
.xml- Namespaces
http://schemas.openxmlformats.org/wordprocessingml/2006/main
- XMLDir label
- —
Specification: ECMA-376 Office Open XML
A minimal valid document
Every example on this site is checked against the same parser the workspace uses, so what you see below is known to be well-formed.
<?xml version="1.0" encoding="UTF-8"?>
<w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
<w:body>
<w:p>
<w:pPr><w:pStyle w:val="Heading1"/></w:pPr>
<w:r><w:t>Quarterly report</w:t></w:r>
</w:p>
<w:p>
<w:r><w:t xml:space="preserve">Revenue grew </w:t></w:r>
<w:r><w:rPr><w:b/></w:rPr><w:t>12%</w:t></w:r>
<w:r><w:t> year on year.</w:t></w:r>
</w:p>
</w:body>
</w:document>Other formats
- XML sitemap
- Sitemap index
- RSS 2.0
- Atom 1.0
- SOAP envelope
- XML Schema (XSD)
- WSDL
- XSLT stylesheet
- SVG
- OPML
- RDF/XML
- GPX
- KML
- XLIFF
- UBL Invoice
- JUnit XML
- Maven POM
- SAML 2.0
- Property list
- DocBook 5
- JATS article
- MusicXML 4.0
- MathML
- XSL-FO
- Android manifest
- Android strings
- MSBuild project
- Log4j 2 config
- JaCoCo report
- Checkstyle report
- EPUB package
- XMP metadata
- TEI document
- ISO 20022 pain.001
- HL7 CDA
- TTML captions
- OpenStreetMap XML
Get started
Bring order to the XML your team can't afford to ignore.
Create a free account and get a private workspace to search, validate, diff, and monitor your XML feeds, sitemaps, schemas, and vendor integrations.