Skip to content

command raw word

zmworm edited this page Mar 31, 2026 · 23 revisions

raw / raw-set - Word (.docx)

Raw XML operations for Word documents.

Available Parts

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)

XPath Namespace Prefixes

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), and wp14 (Word Drawing 2010) namespaces are available in --xml fragments but are NOT supported in --xpath expressions.

raw Examples

# 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

raw-set Examples

# 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

add-part Examples

# 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

See Also


Based on OfficeCLI v1.0.28

Clone this wiki locally