Code: Select all
SettingsData *ResourceLoader::LoadSettings(){
SettingsData *return_me = new SettingsData();
IrrlichtDevice *null_device = createDevice(video::EDT_NULL);
IXMLReader *xml_reader = null_device->getFileSystem()->createXMLReader(L"../Data/config.xml");
//keep track of our current section
stringw currentSection = L"";
//while there is more to read
while(xml_reader->read()){
//check the node type
switch (xml_reader->getNodeType()){
//we found a new element
case irr::io::EXN_ELEMENT:{
if (currentSection.empty()){
currentSection = xml_reader->getNodeName();
}
// we are at the end of the current section assignment, now read in the tags themselves
else if (stringw(L"video").equals_ignore_case(xml_reader->getNodeName())){
return_me->ResolutionWidth = xml_reader->getAttributeValueAsInt(L"resolution_width");
return_me->ResolutionHeight = xml_reader->getAttributeValueAsInt(L"resolution_height");
return_me->AntiAiliasingLevel = xml_reader->getAttributeValueAsInt(L"anti_ailiasing");
return_me->Fullscreen = xml_reader->getAttributeValueAsInt(L"fullscreen");
return_me->Vsync = xml_reader->getAttributeValueAsInt(L"vsync");
return_me->DriverType = video::EDT_OPENGL;
}
}
break;
//we found the end of an element
case irr::io::EXN_ELEMENT_END:
//we were at the end of the video section so we reset our tag
currentSection=L"";
break;
}
}
// don't forget to delete the xml reader & device
xml_reader->drop();
null_device->closeDevice();
null_device->drop();
return return_me;
}Code: Select all
<?xml version="1.0"?>
<root> <video resolution_width="1280" resolution_height="720" anti_ailiasing="0" fullscreen="0" vsync="0" /></root>The really wierd part about all of this is that I am loading XML files elsewhere in my code in the exact same fasion. I even made sure theat the encoding of all of the files UTF-32LE. Im really failing to see what I am doing wrong, it seems that the XML reader just does not want to load this file... any one got any ideas? Are there any common mistakes that I may have made with the XML reader?