Can someone write a C++ tutorial on how to use IrrXML to read and write XML files?
I've tried and failed.
irrXML tutorial
-
- Posts: 1029
- Joined: Thu Apr 06, 2006 12:45 am
- Location: Tennesee, USA
- Contact:
Re: irrXML tutorial
There is already one in the documentation lol. BUT it is flawed, it gives you some wrong functions for initializing the reader I think. Let me find some source code that will help you..monkeycracks wrote:Can someone write a C++ tutorial on how to use IrrXML to read and write XML files?
I've tried and failed.
Code: Select all
IXMLReader* xml = device->getFileSystem()->createXMLReader("config.xml");
int vdriver, xres, yres, bits;
bool fullscreen;
while(xml && xml->read())
{
if (core::stringw("config") == xml->getNodeName())
{
vdriver = xml->getAttributeValueAsInt(L"driver");
xres = xml->getAttributeValueAsInt(L"xres");
yres = xml->getAttributeValueAsInt(L"yres");
bits = xml->getAttributeValueAsInt(L"bits");
fullscreen = xml->getAttributeValueAsInt(L"fullscreen");
}
}
Code: Select all
<?xml version="1.0"?>
<!-- Driver Settings Help: 1 = Direct3D9, 2 = Direct3D8, 3 = OPENGL, 4 = Software, 5 = Software Improved-->
<config driver="3" xres="800" yres="600" bits="32" fullscreen="1" />
For the writer it is similar just do this:
Code: Select all
IXMLWriter* xmlr = device->getFileSystem()->createXMLWriter("save.data");
xmlr->writeXMLHeader();
xmlr->writeElement(L"stats",true,health,healthvalue,magic,magicvalue,strength,strengthvalue,smart,smartvalue,somethingelse,somethingelsevalue);
xmlr->drop();
// (healthvalue is value of health, magicvalue is value of magic, etc etc)
// Here is how i set the "magicvalue" for example:
// wchar_t magicvalue[255];
// swprintf(magicvalue, 255, L"%d",[INTEGER GOES HERE]);
// And do that for all values that you set that are ints, use f% instead of d% for floats.
// Or replace the whole of "%d" with the words if you just want a string.
// Remember to place all of this BEFORE the writer code...:P
Cheers.
Last edited by BlindSide on Sun Jan 28, 2007 8:56 pm, edited 1 time in total.
what are you talking about of course can irrliht read xml without the header
but dont forget to drop the writer at the end otherwise the data wont be flushed on the HD
greets,
halan
but dont forget to drop the writer at the end otherwise the data wont be flushed on the HD
greets,
halan
My Blog: http://www.freakybytes.org