config.xml error

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
dennisbarnes
Posts: 12
Joined: Sun Aug 19, 2007 1:11 am
Location: Atlanta Ga U.S.A

config.xml error

Post by dennisbarnes »

Hello I am using Visual C++ Express 2005 and

Irrlicht1.2 game eng and wizIrrlicht


i got the program to build but when i try to get the game to run the win console come on line and this mess

Error while loading Config.xml Config file malformed or is

not there failed to open at line 0
//////////////////////////////////////////////////////////

- <!-- Configuration File Do not delete this Coment bug Id conf-01
-->
- <Config configSrc="PruevadeAttributo">
- <Device devicesrc="Device.xml">
<ScreenResolution height="1024" width="768" />
<Fullscreen value="True" />
<BitsperPixel value="32" />
<Stencilbuffer value="False" />
<Vsync value="True" />
<DriverType type="OpenGL" />
- <!-- other values 'DirectX9' 'Apfelbaum Software'
-->
<ParticleEffects value="True" />
</Device>
<Sound SoundDevice="Audiere" />
</Config>





/////////////////////////////////////////////////////////

- Build started: Project: myProject, Configuration: Debug Win32 ------
Compiling...
Skipping... (no relevant changes detected)
ConfigManager.cpp
Build log was saved at "file://c:\irrlicht-1.2\myProject\Debug\BuildLog.htm"
myProject - 0 error(s), 0 warning(s)
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped

:? Can some help me fix this problem
thank you
Umbra
Posts: 19
Joined: Sun Aug 26, 2007 12:54 pm

Post by Umbra »

You dont seem to have any root element ?

if im not mistaken it should look something like this :

<?xml version="1.0" encoding="UTF-8"?> <!-- optional -->

<somename>
Your stuff
</somename>

hrm nevermind i missed it first time i read it how ever shouldnt this line
- <Config configSrc="PruevadeAttributo">
look like
<Config configSrc="PruevadeAttributo">
TomiZ
Posts: 40
Joined: Wed Aug 29, 2007 6:02 am
Location: Poland
Contact:

Post by TomiZ »

Umbra wrote:hrm nevermind i missed it first time i read it how ever shouldnt this line
- <Config configSrc="PruevadeAttributo">
look like
<Config configSrc="PruevadeAttributo">
Characters that are not between of '<' and '>' are ignored.

dennisbarnes could you post fragment of your code?
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

Characters that are not between of '<' and '>' are ignored.
I'm pretty sure that is not true. Consider HTML [a subset of XML] for example...

Code: Select all

<html>
  <head>
    <title>
      This is the title of the page. It is not ignored.
    </title>
  <head>
  <body>
    This is the body of the html page. It is not ignored.
  </body>
</html>
The Irrlicht XML reader may ignore that text, but it should not be ignored. Other XML parsers definitely don't ignore it. The XML format has a comment syntax and it should be used for comments.

The XML itself looks valid to me. I'm assuming that the - shown in the original XML is just copy/paste from an XML editor. You might want to put an XML header in there, but, as mentioned by Umbra it should be optional.

Code: Select all

<!-- Configuration File Do not delete this Coment bug Id conf-01 --> 
<Config configSrc="PruevadeAttributo"> 
  <Device devicesrc="Device.xml"> 
    <ScreenResolution height="1024" width="768" /> 
    <Fullscreen value="True" /> 
    <BitsperPixel value="32" /> 
    <Stencilbuffer value="False" /> 
    <Vsync value="True" /> 
    <DriverType type="OpenGL" /><!-- other values 'DirectX9' 'Apfelbaum Software' --> 
    <ParticleEffects value="True" /> 
  </Device> 
  <Sound SoundDevice="Audiere" /> 
</Config> 
The error message indicates that the file is formatted incorrectly or the file itself cannot be found. I'd guess that it is the latter. Either way, you should be able to use the debugger to step into the code that loads the XML. That should help you to see why the file could not be loaded.

You might also try removing the first comment line. I know it says not to remove it, but there could be a bug in the parser that doesn't like a comment starting at the first character in the file.

Travis
dennisbarnes
Posts: 12
Joined: Sun Aug 19, 2007 1:11 am
Location: Atlanta Ga U.S.A

config.xml error

Post by dennisbarnes »

hello ok i am newb if this is not the right code you need to
look at let me know so i can post the right code for you


include "Game.h"


CGame::CGame()
{
}

//! Main game loop
bool CGame::run()
{
// seen the actual FPS in caption;


// Name of game, displayed in window if windowed
//m_GameManager.getDevice()->setWindowCaption(L"Game Framework");

// Keep running game loop if device exists
while(m_GameManager.getDevice()->run())
{


thankyou
TomiZ
Posts: 40
Joined: Wed Aug 29, 2007 6:02 am
Location: Poland
Contact:

Post by TomiZ »

vitek wrote: I'm pretty sure that is not true. Consider HTML [a subset of XML] for
I mean that this " - " before "<Config configSrc="PruevadeAttributo">" will be ignored, because it will be returned by XML parser as EXN_TEXT, and when you are reading this file, you have to check if XML->getNodeType() ill return EXN_ELEMENT (if you want to read some useful data from xml file posted above). Of course in Irrlicht parser. I checked this file, and it's really work.

This is sample code that works witch dennisbarnes xml file from first post.

Code: Select all


	// set default parametrs
	irr::core::stringc configSrc = "something";
	irr::core::stringc deviceSrc = "some file.xml";
	irr::s32 screenWidth  = 800;
	irr::s32 screenHeight = 600;
	bool fullscreen = false;
	irr::s32 bitperpixel = 32;

	// etc
	

	irr::io::IXMLReaderUTF8 *XML = tmpDevice->getFileSystem()->createXMLReaderUTF8("main.xml");
	if(XML == NULL)
	{
		printf("Can't open file\n");

	}
	else
	{


		while (XML && XML->read())
		{
			core::stringw element = XML->getNodeName(); 
			io::EXML_NODE Typ = XML->getNodeType();
			switch (Typ) 
			{ 
			case io::EXN_ELEMENT: 
	
				if (element == "ScreenResolution") 
				{ 
					screenWidth     = XML->getAttributeValueAsInt("width");
					screenHeight    = XML->getAttributeValueAsInt("height"); 
				} else
				if (element == "Config") 
				{ 

					configSrc  = XML->getAttributeValue("configSrc"); 
				} else
				if (element == "Device") 
				{ 

					deviceSrc = XML->getAttributeValue("devicesrc"); 
				}else
				if (element == "Fullscreen") 
				{ 
					fullscreen = (XML->getAttributeValue("value")==true)? true:false;
				}else
				if (element == "BitsperPixel") 
				{ 
					bitperpixel = XML->getAttributeValueAsInt("value"); 
				}
				
				
			}	
		}
		XML->drop();
	}
	printf("configSrc = %s\ndeviceSrc = %s\nscreenWidth = %d\nscreenHeight = %d\n", configSrc.c_str(), deviceSrc.c_str(), screenWidth, screenHeight);
	if(fullscreen)
		printf("fullscreen = true\n");
	else
		printf("fullscreen = false\n");
	
	printf("bitperpixel = %d\n", bitperpixel );
	

BTW. you screen size is width 768 and height 1024.
dennisbarnes
Posts: 12
Joined: Sun Aug 19, 2007 1:11 am
Location: Atlanta Ga U.S.A

Post by dennisbarnes »

hello Tomiz if i understand your mess you want the configmanger file I hope this is the right file

Tomzi thank you for all your help :D


#include "ConfigManager.h"

CConfigManager::CConfigManager(void)
{
IntConfigReader();
}

CConfigManager::~CConfigManager(void)
{
}


//! Reads in the parameters used for the createDevice function.
void CConfigManager::readDeviceOptions()
{
TiXmlElement *pDevice = pConfig->FirstChild("Device")->ToElement();
if(pDevice==NULL || doc.ErrorId()==4 || doc.ErrorId()==9)
{
ErrorMessage("Device tag", doc.ErrorCol());
}else{
setScreenResolution(pDevice);
setFullscreen(pDevice);
setBitsperPixel(pDevice);
setStencilbuffer(pDevice);
setVsync(pDevice);
setDriverType(pDevice);
setParticleEffects(pDevice);

DEBUGLOG<<"Reading of Device tag Done ..."<<endl;
}
}


// Set Screen resolution, use standard sizes ie 640x480, 800x600, 1024x768, 1200x1400 etc
void CConfigManager::setScreenResolution(TiXmlElement *pDeviceRoot)
{
// use to clean the variable so we dont have do make new each time just re use
attr=NULL;

TiXmlElement *ScreenResolution = pDeviceRoot->FirstChild("ScreenResolution")->ToElement();
if(ScreenResolution==NULL || doc.ErrorId()==4 || doc.ErrorId()==9)
{
ErrorMessage("Screen Resolution tag ",doc.ErrorCol());
}else{

attr=ScreenResolution->FirstAttribute();
if(attr==NULL)
{
ErrorMessage("Height or Width atribute ",doc.ErrorCol());
}
while(attr)
{
DeviceConfig[attr->Name()]=attr->Value();
attr=attr->Next();
}

DEBUGLOG<<"Screen resolution: " + DeviceConfig["height"] + " x " + DeviceConfig["width"]<<endl;
}
}

//! Sets the FullScreen or Windowed mode parameter
void CConfigManager::setFullscreen(TiXmlElement *pDeviceRoot)
{

// use to clean the variable so we dont have do make new each time just re use
attr=NULL;
TiXmlElement *Fullscreen = pDeviceRoot->FirstChild("Fullscreen")->ToElement();
if(Fullscreen==NULL || doc.ErrorId()==4 || doc.ErrorId()==9)
{
ErrorMessage("Full screen tag ",doc.ErrorCol());
}else{

attr=Fullscreen->FirstAttribute();
if(attr==NULL)
{
ErrorMessage("Full screen tag ",doc.ErrorCol());
}

DeviceConfig["FullscreenValue"]=attr->Value();

DEBUGLOG<<"Fullscreen: " + DeviceConfig["FullscreenValue"]<<endl;
}
}

//! Sets the Bits per pixel setting, 16 or 32.
void CConfigManager::setBitsperPixel(TiXmlElement *pDeviceRoot)
{
// use to clean the variable so we dont have do make new each time just re use
attr=NULL;
TiXmlElement *BitsperPixel = pDeviceRoot->FirstChild("BitsperPixel")->ToElement();
if(BitsperPixel==NULL || doc.ErrorId()==4 || doc.ErrorId()==9)
{
ErrorMessage("Bits per Pixel tag ",doc.ErrorCol());
}else{
attr=BitsperPixel->FirstAttribute();
if(attr==NULL)
{
ErrorMessage("Bits per Pixel tag ",doc.ErrorCol());
}

DeviceConfig["BitsperPixelValue"]=attr->Value();

DEBUGLOG<<"Bits per pixel: " + DeviceConfig["BitsperPixelValue"]<<endl;
}
}

//! Sets shadows, true or false.
void CConfigManager::setStencilbuffer(TiXmlElement *pDeviceRoot)
{
// use to clean the variable so we dont have do make new each time just re use
attr=NULL;
TiXmlElement *Stencilbuffer = pDeviceRoot->FirstChild("Stencilbuffer")->ToElement();
if(Stencilbuffer==NULL || doc.ErrorId()==4 || doc.ErrorId()==9)
{
ErrorMessage("Stencil buffer tag ",doc.ErrorCol());
}else{
attr=Stencilbuffer->FirstAttribute();
if(attr==NULL)
{
ErrorMessage("Stencil buffer tag ",doc.ErrorCol());
}

DeviceConfig["StencilbufferValue"]=attr->Value();

DEBUGLOG<<"Shadows: " + DeviceConfig["StencilbufferValue"]<<endl;
}
}

//! Sets the vertical retrace option, true or false
void CConfigManager::setVsync(TiXmlElement *pDeviceRoot)
{
// use to clean the variable so we dont have do make new each time just re use
attr=NULL;
TiXmlElement *Vsync = pDeviceRoot->FirstChild("Vsync")->ToElement();
if(Vsync==NULL || doc.ErrorId()==4 || doc.ErrorId()==9)
{
ErrorMessage("Vsync tag ",doc.ErrorCol());
}else{
attr=Vsync->FirstAttribute();
if(attr==NULL)
{
ErrorMessage("Vsync buffer tag ",doc.ErrorCol());
}
DeviceConfig["VsyncValue"]=attr->Value();

DEBUGLOG<<"Vsync: " + DeviceConfig["VsyncValue"]<<endl;
}
}

//! Sets the driver type
void CConfigManager::setDriverType(TiXmlElement *pDeviceRoot)
{
// use to clean the variable so we dont have do make new each time just re use
attr=NULL;
TiXmlElement *DriverType = pDeviceRoot->FirstChild("DriverType")->ToElement();
if(DriverType==NULL || doc.ErrorId()==4 || doc.ErrorId()==9){
ErrorMessage("Driver Type tag ",doc.ErrorCol());
}else{
attr=DriverType->FirstAttribute();
if(attr==NULL)
{
ErrorMessage("Driver Type tag ",doc.ErrorCol());
}
DeviceConfig["DriverType"]=attr->Value();

DEBUGLOG<<"Device type: " + DeviceConfig["DriverType"]<<endl;
}

}

//! Sets Particle effects, true or false
void CConfigManager::setParticleEffects(TiXmlElement *pDeviceRoot)
{
// use to clean the variable so we dont have do make new each time just re use
attr=NULL;
TiXmlElement *ParticleEffects = pDeviceRoot->FirstChild("ParticleEffects")->ToElement();
if(ParticleEffects==NULL || doc.ErrorId()==4 || doc.ErrorId()==9)
{
ErrorMessage("ParticleEffects tag ",doc.ErrorCol());
}else{
attr=ParticleEffects->FirstAttribute();
if(attr==NULL)
{
ErrorMessage("Particle Effects tag ",doc.ErrorCol());
}
DeviceConfig["ParticleEffectsValue"]=attr->Value();
DEBUGLOG<<"Particle effects: " + DeviceConfig["ParticleEffectsValue"]<<endl;
}
}

//______________________________________________________________________


// Loging Methods
//______________________________________________________________________

void CConfigManager::ErrorMessage(const char *pErrorTag,int ErrorCol)
{
LOG<<"\n Error: the Config.xml is malformed"<<endl;
LOG<< pErrorTag <<" tag not found or malformed at line "<<ErrorCol<<endl;
LOG<<"For more information see the Web Page"<<endl;
LOG<<"or the documentation"<<endl;
}

void CConfigManager::ErrorMessage(const char *pErrorTag){
LOG<<"\n Error: the Config.xml is malformed"<<endl;
LOG<< pErrorTag <<" tag not found or malformed at line "<<endl;
LOG<<"For more information see the Web Page"<<endl;
LOG<<"or the documentation"<<endl;

}



//______________________________________________________________________


//! Initialise config reader
void CConfigManager::IntConfigReader(){

if(!doc.LoadFile("Config.xml"))
{

LOG<<"\n Error while loading Config.xml"<<endl;
LOG<<"Config file malformed or is not there"<<endl;
LOG<<doc.ErrorDesc()<<" at line :"<<doc.ErrorRow()<<endl;

}else{
DEBUGLOG<<"Loading Config.xml Done"<<endl; ;
}


pConfig = doc.FirstChild("Config")->ToElement();
if(pConfig==NULL || doc.ErrorId()==4 || doc.ErrorId()==9){

ErrorMessage("Config Tag",doc.ErrorCol());

}else{
readDeviceOptions();
readSoundOptions();
}
}


//-----------------------------------------------------------------------------
// Public methods
// Get Methods

bool CConfigManager::getVsync()
{
return convertToBoolean(DeviceConfig["VsyncValue"]);
}

bool CConfigManager::getStencilbuffer()
{
return convertToBoolean(DeviceConfig["StencilbufferValue"]);
}

bool CConfigManager::getFullscreen()
{
return convertToBoolean(DeviceConfig["FullscreenValue"]);
}

irr::core::dimension2d<irr::s32> CConfigManager::getScreenResolution()
{
return irr::core::dimension2d<irr::s32>(convertToInt(DeviceConfig["height"]),
convertToInt(DeviceConfig["width"]));
}

bool CConfigManager::getParticleEffects()
{
return convertToBoolean(DeviceConfig["ParticleEffectsValue"]);
}


//! return valid driver types
irr::video::E_DRIVER_TYPE CConfigManager::getDriverType()
{
if(DeviceConfig["DriverType"]=="OpenGL")
return irr::video::EDT_OPENGL;
else if (DeviceConfig["DriverType"]=="DirectX8")
return irr::video::EDT_DIRECT3D8;
else if (DeviceConfig["DriverType"]=="DirectX9")
return irr::video::EDT_DIRECT3D9;
else if (DeviceConfig["DriverType"]=="Irrlicht Software")
return irr::video::EDT_SOFTWARE;
else if (DeviceConfig["DriverType"]=="Apfelbaum Software")
return irr::video::EDT_SOFTWARE2;
else if (DeviceConfig["DriverType"]=="Null")
return irr::video::EDT_NULL;
else{
LOG<<"Error"<< DeviceConfig["DriverType"]<<" is not valid"<<endl;
LOG<<"Using Irrlicht Softwate Driver "<<endl;
LOG<<endl;
return irr::video::EDT_SOFTWARE;
}
}

//! gets the value for bits per pixel
int CConfigManager::getBitsperPixel()
{
int BitsperPixelValue= convertToInt(DeviceConfig["BitsperPixelValue"]);
if(BitsperPixelValue==32)
return 32;
else if (BitsperPixelValue== 16)
return 16;
else{
LOG<<"Error the value of Bits per Pixel us not support by Irrlicht"<<endl;
LOG<<"Using 16 bits "<<endl;
LOG<<endl;

return 16;
}
}
TomiZ
Posts: 40
Joined: Wed Aug 29, 2007 6:02 am
Location: Poland
Contact:

Post by TomiZ »

What XML parser are you using?

Its seems that this XML parser just can't read this file. Use debugger to check if doc.LoadFile("Config.xml")) return false.

Code: Select all

//! Initialise config reader 
void CConfigManager::IntConfigReader()
{
  if(!doc.LoadFile("Config.xml"))   // <------
  { 
    LOG<<"\n Error while loading Config.xml"<<endl; 
    LOG<<"Config file malformed or is not there"<<endl; 
    LOG<<doc.ErrorDesc()<<" at line :"<<doc.ErrorRow()<<endl; 
  }
  else
  { 
    DEBUGLOG<<"Loading Config.xml Done"<<endl; ; 
  } 
[code]

You should use Irrlicht parser if its possible. It's realy simple (simple == good and clear).
dennisbarnes
Posts: 12
Joined: Sun Aug 19, 2007 1:11 am
Location: Atlanta Ga U.S.A

Post by dennisbarnes »

Hello Tomasz you ask What XML parser am i using Stylus Studio 2007 XML Enterprise Release 2 I am just starting to learn But I can download
Irrlicht parser and debug with this I will post the code when i come home
Thank you for your help

Tomasz Złamaniec
dennisbarnes
Posts: 12
Joined: Sun Aug 19, 2007 1:11 am
Location: Atlanta Ga U.S.A

Post by dennisbarnes »

:D helllo Tomasz Złamaniec I download the irrxml and add the config.xml to the debug here what happen

------ Build started: Project: irrxml, Configuration: Debug Win32 ------
Compiling...
Skipping... (no relevant changes detected)
test.cpp
Build log was saved at "file://c:\irrxml-1.2\example\Debug\BuildLog.htm"
irrxml - 0 error(s), 0 warning(s)
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========


Build Log Build started: Project: irrxml, Configuration: Debug|Win32
Command Lines Creating temporary file "c:\irrxml-1.2\example\Debug\RSP0000213722236.rsp" with contents
[
/Od /I "../src" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_VC80_UPGRADE=0x0710" /D "_MBCS" /Gm /EHsc /RTC1 /MTd /Fo"Debug\\" /Fd"Debug\vc80.pdb" /W3 /c /Wp64 /ZI /TP ".\test.cpp"
]
Creating command line "cl.exe @"c:\irrxml-1.2\example\Debug\RSP0000213722236.rsp" /nologo /errorReport:prompt"
Output Window Compiling...
Skipping... (no relevant changes detected)
test.cpp
Results Build log was saved at "file://c:\irrxml-1.2\example\Debug\BuildLog.htm"
irrxml - 0 error(s), 0 warning(s)
Post Reply