Page 1 of 1

Parsing XML?

Posted: Mon Jun 19, 2006 10:14 pm
by Kannon
I was wondering if anyone had any luck with home-grown scene graphs in XML. The project I'm currently working on reqires a somewhat customized scene solution. I havn't had any luck with the XML library included in VisualEditor.

Any other XML libraries someone might reccomend. Or does Irrlicht 1.1 (Yes, I'm using it off of the SVN) come with XML support?

How would one go about writing the code to read the XML file? Is it any different than normal C++? (I can do research to figure that out, if it's not different.)

Posted: Mon Jun 19, 2006 10:22 pm
by hybrid
Yes, Irrlicht has XML support included. But I think there are no examples using this interface, yet. But you'll find many examples in the forums. Niko also has additional webpages for this interface.

Posted: Tue Jun 20, 2006 3:39 am
by BattleElf
We had trouble using the supplied lib with VisualEditor as well. I think it was because it was compiled with VC6 and we're using VC2005. So I started writing my own loader. Got it to load the skybox and terrain from the xml outputted from VisualEditor and then irrEdit was posted up. Our team's other main programmer is converting the current svn to our stuff so once that's done we'll check out the irrEdit loading support in 1.1.

Posted: Tue Jun 20, 2006 5:58 am
by rdm
A simple function from my simple custom levels class;

Code: Select all

    levelCount = 0;
    IXMLReader* xml;
    try
    {
        xml = Device->getFileSystem()->createXMLReader("levels.xml");

        if(xml != 0)
        {
            stringc temp;

            while(xml && xml->read())
            {
                switch(xml->getNodeType())
                {
                    case EXN_CDATA:
                        temp = xml->getNodeData();

                        if(addLevelNode(temp.c_str()))
                        {
                            levelCount++;
                        }

                    break;
                }
            }

            delete xml;
        }
        else
        {
            levelCount = 0;
        }
    }
    catch(...)
    {
        delete xml;
        levelCount = 0;
    }
My level data (levels.xml);

Code: Select all

<?xml version="1.0"?>
<levels>
	<level><![CDATA[0021200001110021111122221222222122200111000011100]]></level>
	<level><![CDATA[0022200002120022111222111112111111100222000022200]]></level>
	<level><![CDATA[0022200002120022212222111112222122200212000022200]]></level>
	<level><![CDATA[0000000002220002122000021110000111000002000000000]]></level>
	<level><![CDATA[0000000002120002221000021100011221002222000000000]]></level>
	<level><![CDATA[0000000000002002211200121120012112002222200000000]]></level>
	<level><![CDATA[0021200002120022111222111112111111100222000022200]]></level>
</levels>