The core is just XTNode class. Its definition looks like:
class XTNode:
   self.name : str
   self.pair : dict[str, str]
   self.childs : list[XTNode]
XTNode
Every XTNode represents section of XTL file. Due to every section may be named or unnamed,
name member may contain empty string.
pairs are keys and their values defined in node scope.
Access to subsections is done through
childs member.
How to use - example
Firstly, define XTL file named cfg.xtl:
<XTH
    v='100'
<students
    <student0
        name='Ben'
        age='23'
    <student1
        name='John
        age='28'
        <grades
            physical_education='4'
            biology='3'
            chemistry='2'
            physics='5'
<
    unnamed_key='ghf'
Now define our Python code in test.py:
import xtlp_r100 as xtlp
def display_content(Nodes : list[xtlp.XTNode]) -> None:
    for n in Nodes:
        print("Node name: {}".format(N.name))
        for P in N.pairs.items():
            print("Pair: {}".format(P))
        display_content(N.childs);
stack = xtlp.make_stack("cfg.xtl")
display_content(stack);
As you can see - usage is simple; just call
make_stack function from xtlp module and you can read all nodes by
stack variable.
Next step is just to display recursively all of them (and their pairs) into console. After running our script content of cfg.xtl is printed:
Node name: XTH
Pair: v = 100
Node name: students
Node name: student0
Pair: age = 23
Pair: name = Ben
Node name: student1
Pair: age = 28
Pair: name = John
Node name: grades
Pair: biology = 3
Pair: chemistry = 2
Pair: physical_education = 4
Pair: physics = 5
Node name: null
Pair: unnamed_key = ghf
Make some attention for node named
null. This is unnamed section - just XTLP automatically renames unnamed sections into
null.