C++ and XML

xmllogo

There are plenty of ways of utilizing XML in your game. From stucturing your dialogue trees to organizing the entities in your game, XML may be your best choice for most of your game’s needs. If you Google the interwebs, you will find several ways to process XML with C++. For one, if you want read-and-write capabilities, you can use the popular Xerces-C++ XML Parser (DOM, SAX, SAX2).

But if your XML isn’t super humungous (GBs) and you only want to read in an XML file, why not consider Dan’s BXMLNode? He calls it the “simplest XML file reader in the world” because it’s just that simple. With only 500 lines of code and a liberal license (MIT), you can just plug the code right into your engine to instantly read XML files. However, I do recommend you wrap this code in a class in case you ever want to switch out the reader for some other code.

You can download the C++ version (bxmlnode.cpp), the C version (bxmlnode.c) and the Visual C++ 6.0 project version (bxmlnode.zip).

[Edit]

XML _Node Class Source Code (C++)

I attached the class that I use in my game. This class basically wraps around bxmlnode with some nice features such as searching for tags, altering the XML, saving to file, and other XMLiciousness. Sorry I have no time to document this, but feel free to email me with any questions. Also, opted to use STL vectors because I’m a lazy asian.

Download: xml_node.zip


Subscribe to comments Posted on 04.08.09 to Game Development, How To by Eddie
Post Tags:

Browse Timeline


Comments ( 2 )

You’re right about XML and that class sounds useful, but be careful about using GPL code. Using something under the GPL means that your own code must be licensed under a GPL compliant license. This means your code is no longer proprietary. So, if you do adopt it when and where can I find the source code for Psy Farmer? :-D

Alex Schearer added these pithy words on Apr 09, 2009 @ 11:55 am

Oh no! Please don’t tell Richard Stallman!!

Eddie added these pithy words on Apr 09, 2009 @ 1:27 pm

Add a Comment


XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">


© Copyright 2012 Illogic Tree | Powered by WordPress | Theme by Zidalgo | Log in