-
Notifications
You must be signed in to change notification settings - Fork 102
command raw word
zmworm edited this page Mar 31, 2026
·
23 revisions
Raw XML operations for Word documents.
| Part Path | Description |
|---|---|
/document (default) |
Main document body XML |
/styles |
Style definitions XML |
/numbering |
List/numbering definitions XML |
/settings |
Document settings XML |
/header[N] |
Header XML (1-based index) |
/footer[N] |
Footer XML (1-based index) |
/comments |
Comments part XML |
/chart[N] |
Embedded chart XML (1-based) |
| Prefix | Namespace | Description |
|---|---|---|
w |
WordprocessingML | Main Word namespace (paragraphs, runs, tables) |
r |
Relationships | Relationship references |
a |
DrawingML | Drawing elements |
mc |
Markup Compatibility | Compatibility markup |
wp |
Word Drawing | Drawing positioning |
Note: The
wps(Word Drawing Shape),v(VML), andwp14(Word Drawing 2010) namespaces are available in--xmlfragments but are NOT supported in--xpathexpressions.
# View main document XML
officecli raw report.docx
# View document body (same as above, /document is default)
officecli raw report.docx /document
# View style definitions
officecli raw report.docx /styles
# View numbering/list definitions
officecli raw report.docx /numbering
# View header XML (1-based)
officecli raw report.docx /header[1]
# View footer XML
officecli raw report.docx /footer[1]
# View document settings
officecli raw report.docx /settings# Append a paragraph to the document body
officecli raw-set report.docx /document \
--xpath "//w:body" \
--action append \
--xml '<w:p><w:r><w:t>Appended paragraph</w:t></w:r></w:p>'
# Remove all bold formatting
officecli raw-set report.docx /document \
--xpath "//w:b" \
--action remove
# Set paragraph justification to center
officecli raw-set report.docx /document \
--xpath "//w:pPr/w:jc" \
--action setattr \
--xml "w:val=center"
# Insert a heading before paragraph 2
officecli raw-set report.docx /document \
--xpath "//w:body/w:p[2]" \
--action insertBefore \
--xml '<w:p><w:pPr><w:pStyle w:val="Heading1"/></w:pPr><w:r><w:t>New Heading</w:t></w:r></w:p>'
# Replace first paragraph
officecli raw-set report.docx /document \
--xpath "//w:body/w:p[1]" \
--action replace \
--xml '<w:p><w:pPr><w:jc w:val="center"/></w:pPr><w:r><w:rPr><w:b/></w:rPr><w:t>Replaced</w:t></w:r></w:p>'
# Remove all highlighting
officecli raw-set report.docx /document \
--xpath "//w:highlight" \
--action remove# Create a new chart part
officecli add-part report.docx / --type chart
# Returns: relId=rId7, partPath=/word/charts/chart1.xml
# Create a new header part
officecli add-part report.docx / --type header
# Returns: relId=rId8, partPath=/word/header2.xml- raw - Command syntax
- Word Reference - All Word elements
Based on OfficeCLI v1.0.28