Click or drag to resize

NodeType Enumeration

Specifies the type of a Word document node.

Namespace:  Aspose.Words
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 21.8.0

ExpandedSyntax

public enum NodeType

ExpandedMembers

  Member nameValueDescription
Any0 Indicates all node types. Allows to select all children.
Document1

A Document object that, as the root of the document tree, provides access to the entire Word document.

A Document node can have Section nodes.

Section2

A Section object that corresponds to one section in a Word document.

A Section node can have Body and HeaderFooter nodes.

Body3

A Body object that contains the main text of a section (main text story).

A Body node can have Paragraph and Table nodes.

HeaderFooter4

A HeaderFooter object that contains text of a particular header or footer inside a section.

A HeaderFooter node can have Paragraph and Table nodes.

Table5

A Table object that represents a table in a Word document.

A Table node can have Row nodes.

Row6

A row of a table.

A Row node can have Cell nodes.

Cell7

A cell of a table row.

A Cell node can have Paragraph and Table nodes.

Paragraph8

A paragraph of text.

A Paragraph node is a container for inline level elements Run, FieldStart, FieldSeparator, FieldEnd, FormField, Shape, GroupShape, Footnote, Comment, SpecialChar, as well as BookmarkStart and BookmarkEnd.

BookmarkStart9

A beginning of a bookmark marker.

BookmarkEnd10

An end of a bookmark marker.

EditableRangeStart11

A beginning of an editable range.

EditableRangeEnd12

An end of an editable range.

MoveFromRangeStart13

A beginning of an MoveFrom range.

MoveFromRangeEnd14

An end of an MoveFrom range.

MoveToRangeStart15

A beginning of an MoveTo range.

MoveToRangeEnd16

An end of an MoveTo range.

GroupShape17

A group of shapes, images, OLE objects or other group shapes.

A GroupShape node can contain other Shape and GroupShape nodes.

Shape18

A drawing object, such as an OfficeArt shape, image or an OLE object.

A Shape node can contain Paragraph and Table nodes.

Comment19

A comment in a Word document.

A Comment node can have Paragraph and Table nodes.

Footnote20

A footnote or endnote in a Word document.

A Footnote node can have Paragraph and Table nodes.

Run21

A run of text.

FieldStart22

A special character that designates the start of a Word field.

FieldSeparator23

A special character that separates the field code from the field result.

FieldEnd24

A special character that designates the end of a Word field.

FormField25

A form field.

SpecialChar26

A special character that is not one of the more specific special character types.

SmartTag27

A smart tag around one or more inline structures (runs, images, fields,etc.) within a paragraph

StructuredDocumentTag28

Allows to define customer-specific information and its means of presentation.

StructuredDocumentTagRangeStart29

A start of ranged structured document tag which accepts multi-sections content.

StructuredDocumentTagRangeEnd30

A end of ranged structured document tag which accepts multi-sections content.

GlossaryDocument31

A glossary document within the main document.

BuildingBlock32

A building block within a glossary document (e.g. glossary document entry).

CommentRangeStart33 A marker node that represents the start of a commented range.
CommentRangeEnd34 A marker node that represents the end of a commented range.
OfficeMath35

An 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.

SubDocument36 A subdocument node which is a link to another document.
System37 Reserved for internal use by Aspose.Words.
Null38 Reserved for internal use by Aspose.Words.

ExpandedExamples

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(shape);

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.ChildNodes;

Assert.AreEqual(3, paragraph.ChildNodes.Count);

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

ExpandedSee Also