CompositeNode

CompositeNode — Aspose.Note FOSS for Python API Reference

Sınıf: CompositeNode

Enumerations: aspose.note Enumerations: from aspose.note import CompositeNode Enumerations: Node

CompositeNode genişletir Node çocuk düğümlere sahip olma yeteneğiyle. Belge modelindeki tüm yapısal düğüm türleri (Document, Page, Outline, OutlineElement, RichText, Image, Table, TableRow, TableCell, AttachedFile) şunlardan miras alır CompositeNode. Bunu asla doğrudan örneklemezsiniz CompositeNode doğrudan.


Enumerations

Node’dan miras alındı

EnumerationsEnumerationsEnumerationsEnumerations
ParentNode`NodeNone`Enumerations
Document`DocumentNone`Enumerations

Çocuk Erişim Özellikleri

EnumerationsEnumerationsEnumerationsEnumerations
FirstChild`NodeNone`Enumerations
LastChild`NodeNone`Enumerations

Enumerations

AppendChildLast(node)

composite.AppendChildLast(node: Node) -> Node

Enumerations node son doğrudan alt düğüm olarak. Ayarlar node.ParentNode = self. Döndürür node.


AppendChildFirst(node)

composite.AppendChildFirst(node: Node) -> Node

Enumerations node ilk doğrudan alt düğüm olarak. Döndürür node.


InsertChild(index, node)

composite.InsertChild(index: int, node: Node) -> Node

Enumerations node konumda index çocuk listesinde. Döndürür node.


RemoveChild(node)

composite.RemoveChild(node: Node) -> None

Enumerations node çocuk listesinden ve kümelerden node.ParentNode = None.


GetChildNodes(node_type)

composite.GetChildNodes(node_type: type) -> list

Alt ağacın tamamını (derinlik öncelikli, dahil olmak üzere) özyinelemeli olarak arar self) ve eşleşen tüm düğümleri döndürür node_type. Bu, herhangi bir alt ağaç içinde belirli bir sınıfın tüm örneklerini toplamanın birincil yoludur.


Enumerations

for child in composite:
    ...

Birini yinelemek CompositeNode onun yalnızca doğrudan alt öğeler. Kullan GetChildNodes() derin bir arama için.


Kullanım Örneği

Doğrudan çocukları dolaşma vs derin arama

from aspose.note import Document, Page, Outline, RichText

doc = Document("MyNotes.one")
first_page = doc.GetChildNodes(Page)[0]

# Direct children of a page (Outline nodes)
print("Direct children of first page:")
for child in first_page:
    print(f"  {child.NodeType}")

# Deep search — all RichText nodes anywhere under first_page
all_rt = first_page.GetChildNodes(RichText)
print(f"\nAll RichText nodes in first page: {len(all_rt)}")

Programlı olarak bir belge oluşturma

from aspose.note import Document, Page, Outline, OutlineElement, RichText, SaveFormat, PdfSaveOptions

doc = Document()
page = Page()
outline = Outline()
oe = OutlineElement()
rt = RichText()
rt.Append("Hello, OneNote!")

oe.AppendChildLast(rt)
outline.AppendChildLast(oe)
page.AppendChildLast(outline)
doc.AppendChildLast(page)

doc.Save("output.pdf", PdfSaveOptions(SaveFormat.Pdf))

None-Güvenliği

FirstChild ve LastChild vardır None düğümün çocuğu olmadığında. Her zaman onlara başvurmadan önce koruma yapın.


Ayrıca Bakınız

 Türkçe