Parsing XML?

Post your questions, suggestions and experiences regarding game design, integration of external libraries here. For irrEdit, irrXML and irrKlang, see the
ambiera forums
Post Reply
Kannon
Posts: 20
Joined: Wed Jun 14, 2006 7:27 am

Parsing XML?

Post 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.)
"That is not dead which can eternal lie, And with strange aeons even death may die."
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post 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.
BattleElf
Posts: 18
Joined: Sat Mar 04, 2006 10:55 am
Location: Brisbane, Australia

Post 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.
rdm
Posts: 10
Joined: Mon Jun 19, 2006 2:53 pm

Post 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>
Post Reply