NodeType

Inheritance: java.lang.Object

public class NodeType

Specifies the type of a Word document node.

Examples:

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.setWidth(200.0);
 shape.setHeight(200.0);
 // Note that the 'CustomNodeId' is not saved to an output file and exists only during the node lifetime.
 shape.setCustomNodeId(100);
 shape.setWrapType(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.getChildNodes(NodeType.ANY, false);

 Assert.assertEquals(3, paragraph.getChildNodes(NodeType.ANY, false).getCount());

 for (Node child : (Iterable) children)
     switch (child.getNodeType()) {
         case NodeType.RUN:
             System.out.println("Run contents:");
             System.out.println(MessageFormat.format("\t\"{0}\"", child.getText().trim()));
             break;
         case NodeType.SHAPE:
             Shape childShape = (Shape)child;
             System.out.println("Shape:");
             System.out.println(MessageFormat.format("\t{0}, {1}x{2}", childShape.getShapeType(), childShape.getWidth(), childShape.getHeight()));
             break;
     }
 

Fields

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

Methods

MethodDescription
fromName(String nodeTypeName)
getName(int nodeType)
getValues()
toString(int nodeType)

ANY

public static int ANY

Indicates all node types. Allows to select all children.

BODY

public static int BODY

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

A Body node can have Paragraph and Table nodes.

BOOKMARK_END

public static int BOOKMARK_END

An end of a bookmark marker.

BOOKMARK_START

public static int BOOKMARK_START

A beginning of a bookmark marker.

BUILDING_BLOCK

public static int BUILDING_BLOCK

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

CELL

public static int CELL

A cell of a table row.

A Cell node can have Paragraph and Table nodes.

COMMENT

public static int COMMENT

A comment in a Word document.

A Comment node can have Paragraph and Table nodes.

COMMENT_RANGE_END

public static int COMMENT_RANGE_END

A marker node that represents the end of a commented range.

COMMENT_RANGE_START

public static int COMMENT_RANGE_START

A marker node that represents the start of a commented range.

DOCUMENT

public static int DOCUMENT

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.

EDITABLE_RANGE_END

public static int EDITABLE_RANGE_END

An end of an editable range.

EDITABLE_RANGE_START

public static int EDITABLE_RANGE_START

A beginning of an editable range.

FIELD_END

public static int FIELD_END

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

FIELD_SEPARATOR

public static int FIELD_SEPARATOR

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

FIELD_START

public static int FIELD_START

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

FOOTNOTE

public static int FOOTNOTE

A footnote or endnote in a Word document.

A Footnote node can have Paragraph and Table nodes.

FORM_FIELD

public static int FORM_FIELD

A form field.

GLOSSARY_DOCUMENT

public static int GLOSSARY_DOCUMENT

A glossary document within the main document.

GROUP_SHAPE

public static int GROUP_SHAPE

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

A GroupShape node can contain other Shape and GroupShape nodes.

public static int HEADER_FOOTER

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

A HeaderFooter node can have Paragraph and Table nodes.

MOVE_FROM_RANGE_END

public static int MOVE_FROM_RANGE_END

An end of an MoveFrom range.

MOVE_FROM_RANGE_START

public static int MOVE_FROM_RANGE_START

A beginning of an MoveFrom range.

MOVE_TO_RANGE_END

public static int MOVE_TO_RANGE_END

An end of an MoveTo range.

MOVE_TO_RANGE_START

public static int MOVE_TO_RANGE_START

A beginning of an MoveTo range.

NULL

public static int NULL

Reserved for internal use by Aspose.Words.

OFFICE_MATH

public static int OFFICE_MATH

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.

PARAGRAPH

public static int PARAGRAPH

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.

ROW

public static int ROW

A row of a table.

A Row node can have Cell nodes.

RUN

public static int RUN

A run of text.

SECTION

public static int SECTION

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

A Section node can have Body and HeaderFooter nodes.

SHAPE

public static int SHAPE

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

A Shape node can contain Paragraph and Table nodes.

SMART_TAG

public static int SMART_TAG

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

SPECIAL_CHAR

public static int SPECIAL_CHAR

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

STRUCTURED_DOCUMENT_TAG

public static int STRUCTURED_DOCUMENT_TAG

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

STRUCTURED_DOCUMENT_TAG_RANGE_END

public static int STRUCTURED_DOCUMENT_TAG_RANGE_END

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

STRUCTURED_DOCUMENT_TAG_RANGE_START

public static int STRUCTURED_DOCUMENT_TAG_RANGE_START

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

SUB_DOCUMENT

public static int SUB_DOCUMENT

A subdocument node which is a link to another document.

SYSTEM

public static int SYSTEM

Reserved for internal use by Aspose.Words.

TABLE

public static int TABLE

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

A Table node can have Row nodes.

length

public static int length

fromName(String nodeTypeName)

public static int fromName(String nodeTypeName)

Parameters:

ParameterTypeDescription
nodeTypeNamejava.lang.String

Returns: int

getName(int nodeType)

public static String getName(int nodeType)

Parameters:

ParameterTypeDescription
nodeTypeint

Returns: java.lang.String

getValues()

public static int[] getValues()

Returns: int[]

toString(int nodeType)

public static String toString(int nodeType)

Parameters:

ParameterTypeDescription
nodeTypeint

Returns: java.lang.String