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.

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.


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"Document : {rt.Document is doc}")
    if rt.ParentNode is not None:
        print(f"Parent   : {type(rt.ParentNode).__name__}")
    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