Node — Aspose.Note FOSS for Python API Reference

Class: Node

Package: aspose.note Import: from aspose.note import Node

Node is the abstract base class for every element in the OneNote document object model. All concrete node types (Document, Page, Outline, OutlineElement, RichText, Image, AttachedFile, etc.) inherit from Node. You never instantiate Node directly.


Properties

PropertyTypeAccessDescription
ParentNodeNode | NoneReadThe parent node in the document tree. None for the root Document node.
DocumentDocument | NoneReadWalks up the ancestor chain and returns the root Document. Returns None if this node is not yet attached to a document.
NodeTypeNodeTypeReadIdentifies the concrete node type as a NodeType enum value.

Methods

Accept(visitor)

node.Accept(visitor: DocumentVisitor) -> None

Dispatches the appropriate VisitXxxStart / VisitXxxEnd methods on the visitor for this node type. Override in subclasses to implement double-dispatch.


NodeType Values

Node.NodeType returns one of the following NodeType enum values:

ValueDescription
NodeType.DocumentRoot document node
NodeType.PageOneNote page
NodeType.OutlinePositional outline container
NodeType.OutlineElementLeaf content container
NodeType.RichTextStyled text block
NodeType.ImageEmbedded image
NodeType.TableTable
NodeType.AttachedFileEmbedded file attachment

Usage Example

Inspect any node’s position in the tree

from aspose.note import Document, RichText

doc = Document("MyNotes.one")
for rt in doc.GetChildNodes(RichText):
    # Every RichText is a Node — access parent and document via Node properties
    print(f"NodeType : {rt.NodeType}")
    print(f"Document : {rt.Document is doc}")
    if rt.ParentNode is not None:
        print(f"Parent   : {rt.ParentNode.NodeType}")
    print()

None-Safety

ParentNode is None only for the root Document. Document is None only when a node has been created but not yet attached to a document tree.


See Also