Help needed with XML reader/writer
Posted: Fri Aug 22, 2008 8:25 pm
i want to make a settings.xml that will keep the info about screen resolution, v-sync, antialiasing, full screen options.
so my code is:
core::stringw AntiA,FullScr,VSync;
core::stringc Width, Height;
....
io::IXMLReader* xml2 = device->getFileSystem()->createXMLReader(
"settings.xml");
while(xml2 && xml2->read())
{
switch(xml2->getNodeType())
{
case io::EXN_TEXT:
Width = xml2->getAttributeValue(L"Width");
Height = xml2->getAttributeValue(L"Height");
FullScr = xml2->getAttributeValue(L"FullScreen");
AntiA = xml2->getAttributeValue(L"AntiAlias");
VSync = xml2->getAttributeValue(L"VSync");
break;
}
}
if (xml2)
xml2->drop();
....
param.WindowSize.Width = Width.c_str();
param.WindowSize.Height = Height.c_str();
param.AntiAlias = AntiA.c_str();
param.Fullscreen = FullScr.c_str();
param.Vsync = VSync.c_str();
and the xml file:
<settings>
Width="800"
Height="600"
AntiAlias="true"
FullScreen="false"
VSync="false"
</settings>
but still gives some errors and doesn't read the xml data
also i want to make an xml writer to write new values in settings.xml when new screen resolution is set from the options menu...and the new setting to be loaded next time the program is open.
any suggestions could be usefull
10x
so my code is:
core::stringw AntiA,FullScr,VSync;
core::stringc Width, Height;
....
io::IXMLReader* xml2 = device->getFileSystem()->createXMLReader(
"settings.xml");
while(xml2 && xml2->read())
{
switch(xml2->getNodeType())
{
case io::EXN_TEXT:
Width = xml2->getAttributeValue(L"Width");
Height = xml2->getAttributeValue(L"Height");
FullScr = xml2->getAttributeValue(L"FullScreen");
AntiA = xml2->getAttributeValue(L"AntiAlias");
VSync = xml2->getAttributeValue(L"VSync");
break;
}
}
if (xml2)
xml2->drop();
....
param.WindowSize.Width = Width.c_str();
param.WindowSize.Height = Height.c_str();
param.AntiAlias = AntiA.c_str();
param.Fullscreen = FullScr.c_str();
param.Vsync = VSync.c_str();
and the xml file:
<settings>
Width="800"
Height="600"
AntiAlias="true"
FullScreen="false"
VSync="false"
</settings>
but still gives some errors and doesn't read the xml data
also i want to make an xml writer to write new values in settings.xml when new screen resolution is set from the options menu...and the new setting to be loaded next time the program is open.
any suggestions could be usefull
10x