Archive 17/01/2023.

Xml parsing

rogerdv

Another basic question. I have been looking through the editor scripts, but cant find anything similar to what I want to do. I need to parse some xml files containing game configuration, from simple stuff like entity definition to more complex ones like dialogs (still not designed).
So, my typical xml looks like this:

<entities>
 <entity id="one" name="wahatever" description="WTF"/>
 <entity id="another" name="wahatever 2" description="No idea"/>
 *
 *
</entities>

A more complex one could be:

<item id="hunt-knife" name="Knife" > <property name="speed" value="1.0" type="speed"></property> <property name="range" value="1" type="range"></property> </item>

Can somebody give me a brief guide to iterate through several childs and parse nested xml?

OvermindDL1

UIElement and its base classes in the LoadXML function should be a good example.

rogerdv

Yep, but the code is C++, Im using AS and some things are different, for example, you cant do while (childElem) {}, because AS while requires a boolean.

weitjong

You can check how the Editor itself saves and load its configuration file. It is written in AngelScript.

Azalrion

Look at editorimport.as as well.

        XMLElement compElem = entityElem.GetChild("component");
        while (!compElem.isNull)
        {
            ...

            compElem = compElem.GetNext("component");
        }