Node — Aspose.Note FOSS for Python API Reference

คลาส: Node

Properties: aspose.note Properties: from aspose.note import Node

Node เป็นคลาสฐานเชิงนามธรรมสำหรับทุกองค์ประกอบในโมเดลวัตถุของเอกสาร OneNote ทั้งหมดประเภทโหนดที่เป็นคอนกรีต (Document, Page, Outline, OutlineElement, RichText, Image, AttachedFile, เป็นต้น) สืบทอดจาก Node. คุณไม่ควรสร้างอินสแตนซ์ของ Node โดยตรง.


Properties

PropertiesPropertiesPropertiesProperties
ParentNode`NodeNone`Properties
Document`DocumentNone`Properties

Properties

Accept(visitor)

node.Accept(visitor: DocumentVisitor) -> None

ส่งต่อเมธอดที่เหมาะสม VisitXxxStart / VisitXxxEnd บน visitor สำหรับประเภทโหนดนี้. ให้ทำการ override ในคลาสย่อยเพื่อดำเนินการ double-dispatch.


ตัวอย่างการใช้งาน

ตรวจสอบตำแหน่งของโหนดใด ๆ ในต้นไม้

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

ParentNode คือ None เฉพาะสำหรับราก Document. Document คือ None เฉพาะเมื่อโหนดถูกสร้างขึ้นแล้วแต่ยังไม่ได้แนบเข้ากับต้นไม้เอกสาร.


ดูเพิ่มเติม

 ภาษาไทย