I adapted the sample code to read this:
<?xml version="1.0"?>
<config>
<shadows>no</shadows>
<fullscreen>no</fullscreen>
</config>
the code is this:
io::IXMLReader* xml = device->getFileSystem()->createXMLReader("config2.xml");
core::stringw c_shadows;
core::stringw c_fullsc;
while(xml->read())
{
cout <<"In the while"<<endl;
switch(xml->getNodeType())
{
case io::EXN_TEXT:
cout <<"is a text"<<endl;
if (core::stringw("shadows") == xml->getNodeName()){
c_shadows = xml->getNodeData();
cout << "Found shadows "<<endl;
}
else if (core::stringw("fullscreen") == xml->getNodeName()) {
c_fullsc = xml->getNodeData();
cout << "Found fullscreen "<<endl;
}
break;
}
}
but it justs fall in an endless while loop. What is wrong there?
help with xml parser
help with xml parser
ru guo ni yao ai, ni jiang bu hui shi qu
The problem is probably with how the xml is stored, at the moment Niko's implementation only seems to work with xml saved as unicode. Notepad with windows 2000 can do this, alternativley you can use another editor such as http://www.pcworlddownload.com/system-u ... d-Lite.htm
Try saving the xml in unicode format first to see if it's this thats causing your problem.
________
Vermont Dispensaries
Try saving the xml in unicode format first to see if it's this thats causing your problem.
________
Vermont Dispensaries
Last edited by area51 on Tue Feb 22, 2011 1:00 pm, edited 1 time in total.
It also happened to me. I tried some different formats, but obtained only errors or the endless loop again.
A temporary solution could be adding a node at the end that, when read, ends the parsing proccess. that does work. (I have already done it), but in case of parsing errors the endless loop tends to appear again
A temporary solution could be adding a node at the end that, when read, ends the parsing proccess. that does work. (I have already done it), but in case of parsing errors the endless loop tends to appear again
Re: help with xml parser
Where did you find the sample code? I want to read my config in xml and have the same problem.rogerdv wrote:I adapted the sample code to read this:
Right, for the sample you have up there you would end the loop by stopping the while loop when that tag is reached. I use a parsing bool so that I can stop the parsing when I want. Look at this:
This will exit the reader when the </config> tag is found. We use this and it seems to work fine with Linux.
Code: Select all
while ( xml-read() && mapParsing == true )
{
if (xml1->getNodeType() == irr::io::EXN_ELEMENT_END && irr::core::stringw("config") == xml1->getNodeName() )
mapParsing = false;
}
This will exit the reader when the </config> tag is found. We use this and it seems to work fine with Linux.
you call getNodeName() when the element is of type EXN_TEXT. I beleive getNodeName only works on EXN_ELEMENT and EXN_ELEMENT_END
You do a lot of programming? Really? I try to get some in, but the debugging keeps me pretty busy.
Crucible of Stars
Crucible of Stars
ok, and then how to change renderer.
I have this:
How to convert types?
I have this:
Code: Select all
IrrlichtDevice *device =
createDevice(EDT_NULL, dimension2d<s32>(640, 480), 32, true, false, 0);
core::stringw renderer;
...
if (core::stringw("renderer") == xml->getNodeName()) {
renderer = xml->getNodeData();
...
device = createDevice(renderer, dimension2d<s32>(800, 600), 32, true, false, 0);