XML / SVG importer

Previous topic - Next topic

Kitty Hello

Ye, you're right. This time I'm the requester :P
First, we need an XML parser library. The XML format is pretty easy to read. The hardest thing will be a structure to contain the XML trees.

Here's my suggestiong how to store a tree like stucture:
Code (glbasic) Select




TYPE Tpair
name$
value$
ENDTYPE

TYPE Titem
main   AS Tpair
kids%[] // kid indices
ENDTYPE


GLOBAL gTreePairs[] AS Titem

FUNCTION AllocItem%: name$, value$=""
LOCAL p AS Titem
p.main.name$=name$
p.main.value$=value$
DIMPUSH gTreePairs[], p
RETURN LEN(gTreePairs[])-1
ENDFUNCTION


FUNCTION FreeTree%:
DIM gTreePairs[0]
ENDFUNCTION




FUNCTION AddKid%: item%, kid_item%
DIMPUSH gTreePairs[item%].kids%[], kid_item%
ENDFUNCTION

FUNCTION GetNumKids%: item%
RETURN LEN(gTreePairs[item%].kids[])
ENDFUNCTION

FUNCTION GetKid%: item%, index%
RETURN gTreePairs[item%].kids%[index%]
ENDFUNCTION

FUNCTION GetItemName$: item%
RETURN gTreePairs[item%].main.name$
ENDFUNCTION

FUNCTION SetItemName%: item%, name$
gTreePairs[item%].main.name$ = name$
ENDFUNCTION


FUNCTION GetItemValue$: item%
RETURN gTreePairs[item%].main.value$
ENDFUNCTION

FUNCTION SetItemValue%: item%, name$
gTreePairs[item%].main.value$ = name$
ENDFUNCTION

FUNCTION RemoveKid%: item%, iKid%
DIMDEL gTreePairs[item%].kids%[], iKid%
ENDFUNCTION


Volunteers?

Moru

I've been wanting to do that for ages but I never get the time for it :-(

The problem of building the tree structure looks like I wanted to solve it.