Paper Office
paper-docxAPI referenceoxml.document

CT_Body

paper-docx 0.2.0 API reference

w:body, the container element for the main document story in document.xml.

Attributes

add_p

attributeadd_pCallable[[], CT_P]

get_or_add_sectPr

attributeget_or_add_sectPrCallable[[], CT_SectPr]

inner_content_elements

attributeinner_content_elementsList[CT_P | CT_Tbl]

Generate all w:p and w:tbl elements in this document-body.

Elements appear in document order. Elements shaded by nesting in a w:ins or other "wrapper" element will not be included.

p

attributep
= ZeroOrMore('w:p', successors=('w:sectPr',))

p_lst

attributep_lstList[CT_P]

sectPr

attributesectPrCT_SectPr | None
= ZeroOrOne('w:sectPr', successors=())

tbl

attributetbl
= ZeroOrMore('w:tbl', successors=('w:sectPr',))

tbl_lst

attributetbl_lstList[CT_Tbl]

xml

attributexmlstr

XML string for this element, suitable for testing purposes.

Pretty printed for readability and without an XML declaration at the top.

Functions

add_section_break

funcadd_section_break() -> CT_SectPr

Return w:sectPr element for new section added at end of document.

The last w:sectPr becomes the second-to-last, with the new w:sectPr being an exact clone of the previous one, except that all header and footer references are removed (and are therefore now "inherited" from the prior section).

A copy of the previously-last w:sectPr will now appear in a new w:p at the end of the document. The returned w:sectPr is the sentinel w:sectPr for the document (and as implemented, is the prior sentinel w:sectPr with headers and footers removed).

Returns

docx.oxml.section.CT_SectPr

clear_content

funcclear_content()

Remove all content child elements from this <w:body> element.

Leave the <w:sectPr> element if it is present.

first_child_found_in

funcfirst_child_found_in(*tagnames: str) -> _Element | None

First child with tag in tagnames, or None if not found.

paramtagnamesstr
= ()

Returns

lxml.etree._Element | None

insert_element_before

funcinsert_element_before(elm: ElementBase, *tagnames: str)
paramelmElementBase
paramtagnamesstr
= ()

remove_all

funcremove_all(*tagnames: str) -> None

Remove child elements with tagname (e.g. "a:p") in tagnames.

paramtagnamesstr
= ()

Returns

None

xpath

funcxpath(xpath_str: str) -> Any

Override of lxml _Element.xpath() method.

Provides standard Open XML namespace mapping (nsmap) in centralized location.

paramxpath_strstr

Returns

typing.Any

On this page