irrXML reading error

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
krama757
Posts: 451
Joined: Sun Nov 06, 2005 12:07 am

irrXML reading error

Post by krama757 »

Greetings, I would like the community's help with one of my simple xml parsing errors.
The xml document named default.xml is:
<?xml version="1.0"?>

<map numObjects="0" addWater="1">
<heightmap>./data/maps/HM-257.jpg</heightmap>
<texturemap>./data/textures/maps/HM-257.bmp</texturemap>
<detailmap>./data/textures/env/detailmap.jpg</detailmap>
</map>
IE parses it fine and doesnt return any errors.

The in-game reading is done using:
cout<<"Filename to be opened by loadMap: "<<fileName<<endl;
IXMLReaderUTF8* irrReader = irrDevice->getFileSystem()->createXMLReaderUTF8(fileName);
if(irrReader == 0)
cout<<"File couldnt be opened for reading...xml"<<endl;

string<c8> heightMap;
string<c8> textureMap;
string<c8> detailMap;
int numObjects;
int addWater;

while(irrReader && irrReader->read()){
switch(irrReader->getNodeType()){
case EXN_TEXT:
if(!strcmp("heightmap", irrReader->getNodeName())) //!strcmp is the same as strcmp == 0
heightMap = irrReader->getNodeData();
if(!strcmp("texturemap", irrReader->getNodeName()))
textureMap = irrReader->getNodeData();
if(!strcmp("detailmap", irrReader->getNodeName()))
detailMap = irrReader->getNodeData();
break;
case EXN_ELEMENT:
if(!strcmp("map", irrReader->getNodeName())){
numObjects = irrReader->getAttributeValueAsInt("numObjects");
addWater = irrReader->getAttributeValueAsInt("addWater");
}
break;
}
}

cout<<"Weee: "<<heightMap.c_str()<<endl;

delete irrReader;
I know IrrReader is initialized and the file is found because the irrReader != 0.

For some reason nothing is read into the variables heightMap, textureMap, nor any of the others. Is there is a reason for this?
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

the reason is you're comparing a pointer to a L"multi-byte" char array to a pointer to a "single-byte" char array, use the wide char srting compare (wstrcmp?) and prefix your strings with L, or if you are not comfortable with arrays and stuff, convert to a nice multi-byte string object like the example given in the docs for IrrXML
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
krama757
Posts: 451
Joined: Sun Nov 06, 2005 12:07 am

Post by krama757 »

I see, but doesnt the IXMLReaderUTF8 return char * ? Only the original IXMLReader() returned wchat_t*, no?
Post Reply