Aspose.Words

Node Classes

When Aspose.Words reads a Word document into memory, objects of different types are created to represent various document elements. Every run of text, paragraph, table, section is a node, and even the document itself is a node. Aspose.Words defines a class for every type of document node.

The following illustration is a UML class diagram that shows inheritance between node classes of the Aspose.Words Document Object Model (DOM). The names of abstract classes are in italics. Note that the Aspose.Words DOM also contains non-node classes such as Style, PageSetup, Font, etc that do not participate in the inheritance and they are not shown on this diagram.

 

The following table lists Aspose.Words node classes and their short descriptions.

Aspose.Words Class

Category

Description

Document

Document

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

Section

Document

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

Body

Document

A container for the main text of a section (main text story).

HeaderFooter

Document

A container for text of a particular header or footer inside a section.

GlossaryDocument

Document

Represents the root entry for a glossary document within a Word document.

BuildingBlock

Document

Represents a glossary document entry such as a Building Block, AutoText or an AutoCorrect entry.

Paragraph

Text

A paragraph of text, contains inline nodes.

Run

Text

A run of text with consistent formatting.

BookmarkStart

Text

A beginning of a bookmark marker.

BookmarkEnd

Text

An end of a bookmark marker.

FieldStart

Text

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

FieldSeparator

Text

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

FieldEnd

Text

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

FormField

Text

A form field.

SpecialChar

Text

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

Table

Tables

A table in a Word document.

Row

Tables

A row of a table.

Cell

Tables

A cell of a table row.

Shape

Shapes

An image, shape, textbox or an OLE object in a Word document.

GroupShape

Shapes

A group of shapes.

DrawingML

Shapes

Represents a DrawingML shape, picture, chart or diagram in the document.

Footnote

Annotations

A footnote or endnote in a Word document, contains text of the footnote.

Comment

Annotations

A comment in a Word document, contains text of the comment.

CommentRangeStart

Annotations

Denotes the start of a region of text which has a comment associated with it.

CommentRangeEnd

Annotations

Denotes the end of a region of text which has a comment associated with it.

SmartTag

Markup

Represents a smart tag around one or more inline structures within a paragraph.

CustomXmlMarkup

Markup

Represents Custom XML markup around certain structures in the document.

StructuredDocumentTag

Markup

Represents a structured document tag (content control) within a document.

OfficeMath

Math

Represents an Office math object such as a function, equation or matrix.

 

The following table lists Aspose.Words base node classes that help to form the class hierarchy.

Class

Description

Node

Abstract base class for all nodes of a Word document. Provides basic functionality of a child node.

CompositeNode

Base class for nodes that can contain other nodes. Provides operations to access, insert, remove and select child nodes.

Story 

Text of a Word document is stored in several stories (independent flows of text). This is a base class for section-level stories: Body and HeaderFooter.

InlineStory

Base class for inline-level nodes that can contain a story: Comment and, Footnote.

Inline

Base class for inline-level nodes that consist of a single run of text with font formatting.

DocumentBase

Abstract base class for a main document and glossary document of a Word document

Distinguish Nodes by NodeType

Although the class of the node is sufficient enough to distinguish different nodes from each other, Aspose.Words provides the NodeType enumeration to simplify some API tasks such as selecting nodes of a specific type.

The type of each node can be obtained using the Node.NodeType property. This property returns a NodeType enumeration value. For example, a paragraph node (represented by the Paragraph class) returns NodeType.Paragraph, a table node (represented by the Table class) returns NodeType.Table, and so on.

Example UseNodeType

The following example shows how to use the NodeType enumeration.

[Java]

 

Document doc = new Document();

 

// Returns NodeType.Document

int type = doc.getNodeType();

 

 

Logical Levels in a Document

This documentation sometimes refers to a group of node classes as belonging to a "level" in a document, for example "block-level" or "inline-level" (also known as "inline") nodes. The distinction of levels in a document is purely logical and is not explicitly expressed by inheritance or other means in the Aspose.Words DOM.

The level of the node is used to describe where in the document tree the node would typically occur. The following table lists the logical node levels, descriptions and the classes that belong to each level.

Node Level

Classes

Description

Document level

Section

The top level Document node contains only Section objects.

A Section is a container for stories (independent flows of text) for the main text and optionally headers and footers.

Block level

Paragraph, Table, StructuredDocumentTag, CustomXmlMarkup

Tables and paragraphs are block-level elements and contain other elements.

Custom markup nodes can contain nested block-level nodes.

Inline level

Run, FormField, SpecialChar, FieldChar, FieldStart, FieldSeparator, FieldEnd, Shape, GroupShape, Comment, Footnote, CommentRangeStart, CommentRangeEnd, DrawingML, SmartTag, StructuredDocumentTag, CustomXmlMarkup, BookmarkStart and BookmarkEnd.

Inline occur inside a Paragraph and represent the actual content of the document.

Footnote, Comment and Shape can contain block-level elements.

Custom markup nodes can contain nested inline-level elements