NodeType enumeration

Specifies the type of a Word document node.

public enum NodeType


Any0Indicates all node types. Allows to select all children.
Document1A Document object that, as the root of the document tree, provides access to the entire Word document.
Section2A Section object that corresponds to one section in a Word document.
Body3A Body object that contains the main text of a section (main text story).
HeaderFooter4A HeaderFooter object that contains text of a particular header or footer inside a section.
Table5A Table object that represents a table in a Word document.
Row6A row of a table.
Cell7A cell of a table row.
Paragraph8A paragraph of text.
BookmarkStart9A beginning of a bookmark marker.
BookmarkEnd10An end of a bookmark marker.
EditableRangeStart11A beginning of an editable range.
EditableRangeEnd12An end of an editable range.
MoveFromRangeStart13A beginning of an MoveFrom range.
MoveFromRangeEnd14An end of an MoveFrom range.
MoveToRangeStart15A beginning of an MoveTo range.
MoveToRangeEnd16An end of an MoveTo range.
GroupShape17A group of shapes, images, OLE objects or other group shapes.
Shape18A drawing object, such as an OfficeArt shape, image or an OLE object.
Comment19A comment in a Word document.
Footnote20A footnote or endnote in a Word document.
Run21A run of text.
FieldStart22A special character that designates the start of a Word field.
FieldSeparator23A special character that separates the field code from the field result.
FieldEnd24A special character that designates the end of a Word field.
FormField25A form field.
SpecialChar26A special character that is not one of the more specific special character types.
SmartTag27A smart tag around one or more inline structures (runs, images, fields,etc.) within a paragraph
StructuredDocumentTag28Allows to define customer-specific information and its means of presentation.
StructuredDocumentTagRangeStart29A start of ranged structured document tag which accepts multi-sections content.
StructuredDocumentTagRangeEnd30A end of ranged structured document tag which accepts multi-sections content.
GlossaryDocument31A glossary document within the main document.
BuildingBlock32A building block within a glossary document (e.g. glossary document entry).
CommentRangeStart33A marker node that represents the start of a commented range.
CommentRangeEnd34A marker node that represents the end of a commented range.
OfficeMath35An 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.
SubDocument36A subdocument node which is a link to another document.
System37Reserved for internal use by Aspose.Words.
Null38Reserved for internal use by Aspose.Words.


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

Document doc = new Document();

// Add two runs and one shape as child nodes to the first paragraph of this document.
Paragraph paragraph = (Paragraph)doc.GetChild(NodeType.Paragraph, 0, true);
paragraph.AppendChild(new Run(doc, "Hello world! "));

Shape shape = new Shape(doc, ShapeType.Rectangle);
shape.Width = 200;
shape.Height = 200;
// Note that the 'CustomNodeId' is not saved to an output file and exists only during the node lifetime.
shape.CustomNodeId = 100;
shape.WrapType = WrapType.Inline;

paragraph.AppendChild(new Run(doc, "Hello again!"));

// Iterate through the paragraph's collection of immediate children,
// and print any runs or shapes that we find within.
NodeCollection children = paragraph.GetChildNodes(NodeType.Any, false);

Assert.AreEqual(3, paragraph.GetChildNodes(NodeType.Any, false).Count);

foreach (Node child in children)
    switch (child.NodeType)
        case NodeType.Run:
            Console.WriteLine("Run contents:");
        case NodeType.Shape:
            Shape childShape = (Shape)child;
            Console.WriteLine($"\t{childShape.ShapeType}, {childShape.Width}x{childShape.Height}");

See Also