NodeType enumeration

NodeType enumeration

Specifies the type of a Word document node.


ANYIndicates all node types. Allows to select all children.
DOCUMENTA Document object that, as the root of the document tree, provides access to the entire Word document.
SECTIONA Section object that corresponds to one section in a Word document.
BODYA Body object that contains the main text of a section (main text story).
HEADER_FOOTERA HeaderFooter object that contains text of a particular header or footer inside a section.
TABLEA Table object that represents a table in a Word document.
ROWA row of a table.
CELLA cell of a table row.
PARAGRAPHA paragraph of text.
BOOKMARK_STARTA beginning of a bookmark marker.
BOOKMARK_ENDAn end of a bookmark marker.
EDITABLE_RANGE_STARTA beginning of an editable range.
EDITABLE_RANGE_ENDAn end of an editable range.
MOVE_FROM_RANGE_STARTA beginning of an MoveFrom range.
MOVE_FROM_RANGE_ENDAn end of an MoveFrom range.
MOVE_TO_RANGE_STARTA beginning of an MoveTo range.
MOVE_TO_RANGE_ENDAn end of an MoveTo range.
GROUP_SHAPEA group of shapes, images, OLE objects or other group shapes.
SHAPEA drawing object, such as an OfficeArt shape, image or an OLE object.
COMMENTA comment in a Word document.
FOOTNOTEA footnote or endnote in a Word document.
RUNA run of text.
FIELD_STARTA special character that designates the start of a Word field.
FIELD_SEPARATORA special character that separates the field code from the field result.
FIELD_ENDA special character that designates the end of a Word field.
FORM_FIELDA form field.
SPECIAL_CHARA special character that is not one of the more specific special character types.
SMART_TAGA smart tag around one or more inline structures (runs, images, fields,etc.) within a paragraph
STRUCTURED_DOCUMENT_TAGAllows to define customer-specific information and its means of presentation.
STRUCTURED_DOCUMENT_TAG_RANGE_STARTA start of ranged structured document tag which accepts multi-sections content.
STRUCTURED_DOCUMENT_TAG_RANGE_ENDA end of ranged structured document tag which accepts multi-sections content.
GLOSSARY_DOCUMENTA glossary document within the main document.
BUILDING_BLOCKA building block within a glossary document (e.g. glossary document entry).
COMMENT_RANGE_STARTA marker node that represents the start of a commented range.
COMMENT_RANGE_ENDA marker node that represents the end of a commented range.
OFFICE_MATHAn Office Math object. Can be equation, function, matrix or one of other mathematical objects. Can be a collection of mathematical object and also can contain some non-mathematical objects such as runs of text.
SUB_DOCUMENTA subdocument node which is a link to another document.
SYSTEMReserved for internal use by Aspose.Words.
NULLReserved for internal use by Aspose.Words.


Shows how to traverse through a composite node’s collection of child nodes.

doc = aw.Document()

# Add two runs and one shape as child nodes to the first paragraph of this document.
paragraph = doc.get_child(aw.NodeType.PARAGRAPH, 0, True).as_paragraph()
paragraph.append_child(aw.Run(doc, "Hello world! "))

shape = aw.drawing.Shape(doc, aw.drawing.ShapeType.RECTANGLE)
shape.width = 200
shape.height = 200
# Note that the 'custom_node_id' is not saved to an output file and exists only during the node lifetime.
shape.custom_node_id = 100
shape.wrap_type = aw.drawing.WrapType.INLINE

paragraph.append_child(aw.Run(doc, "Hello again!"))

# Iterate through the paragraph's collection of immediate children,
# and print any runs or shapes that we find within.
children = paragraph.get_child_nodes(aw.NodeType.ANY, False)

self.assertEqual(3, paragraph.get_child_nodes(aw.NodeType.ANY, False).count)

for child in children:
    if child.node_type == aw.NodeType.RUN:
        print("Run contents:")

    elif child.node_type == aw.NodeType.SHAPE:
        child_shape = child.as_shape()
        print(f"\t{child_shape.shape_type}, {child_shape.width}x{child_shape.height}")

See Also