xml reader

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
Armen138
Posts: 298
Joined: Mon Feb 23, 2004 3:38 am

xml reader

Post by Armen138 »

since i included some code to read the level filename from an xml file,
the program crashes with a segfault before it's done with the xml-read loop!
after looking through my code a million times and finding nothing that would
cause this(i think), i tried running the tutorial.9(meshviewer),
which also uses the xml reader, and it does the same thing!
is the xml-reader broken for linux?
do i need to change something? whatsup?
rogerdv
Posts: 93
Joined: Wed Aug 27, 2003 4:20 pm

Post by rogerdv »

Same problem here. Even when I managed to avoid crashes (by creating the file in windows notepad), then the reader simply falls in an endless loop. Rigth now, XML (both read and write) is useless.
ru guo ni yao ai, ni jiang bu hui shi qu
Tyn
Posts: 932
Joined: Thu Nov 20, 2003 7:53 pm
Location: England
Contact:

Post by Tyn »

You could always use TinyXML, that's what I am going to do until a few things have been ironed out with the internal XML reader.
Unarekin
Posts: 60
Joined: Thu Apr 22, 2004 11:02 pm

Post by Unarekin »

Make sure the XML file is saved as Unicode, and not ANSI.
Image
Armen138
Posts: 298
Joined: Mon Feb 23, 2004 3:38 am

Post by Armen138 »

saving as unicode doesn't make any difference!(i think it was saved as unicode in the first place anyway)
xhrit
Posts: 140
Joined: Mon Jun 14, 2004 8:54 am
Location: earth
Contact:

workaround?

Post by xhrit »

I have created a workaround to the issue by forcing the xml read loop to end after a number ov iterations.

Simple method:

int i;
i=0;
while(xml && xml->read() and i<255)
{
i++;

I am going to try a more complex method - including an end tag in the xml file, and set a break variable when the program reads that tag.

complex method :

while(xml && xml->read() and Is_Set_breakXML!="set")
{
//read xml file,
if (core::stringw("breakXML") == xml->getNodeName())
{
Is_Set_breakXML="set";
}
}
Core2Duo E8400 3.0ghz - 2048mb DDR2 800 - geForce 9600 - Slackware12.1

Word-image-symbol programming limits, controls, and imprisons the individual.
Smash the control images, smash the control machine.
rogerdv
Posts: 93
Joined: Wed Aug 27, 2003 4:20 pm

Post by rogerdv »

using a break tag doesnt works, at least under linux. I tried that long time ago
ru guo ni yao ai, ni jiang bu hui shi qu
xhrit
Posts: 140
Joined: Mon Jun 14, 2004 8:54 am
Location: earth
Contact:

...

Post by xhrit »

it works fine. I just tried the second method using this code from tyn's 2080 demo:

// here is XML

<?xml version="1.0"?>

<level X="40" Y="40" tileset="DeadPlanet">

<addClutter TileX="18" TileY="10" Level="0" SubMat="0" Type="1" />

<addCharacter Faction="1" PosX="33" PosY="34" Move="10" Time="60" />

<changeTileTexture TileX="6" TileY="6" Level="0" SubMat="4" />

<endXMLread/>

</level>

// here is c++

CString foo;
while(xml && xml->read() and foo!="set")
{
switch(xml->getNodeType())
{
case io::EXN_ELEMENT:
{
if (core::stringw("endXMLread") == xml->getNodeName())
{
foo="set";
}

...
}
}
}
Last edited by xhrit on Tue Jul 13, 2004 12:57 am, edited 2 times in total.
Core2Duo E8400 3.0ghz - 2048mb DDR2 800 - geForce 9600 - Slackware12.1

Word-image-symbol programming limits, controls, and imprisons the individual.
Smash the control images, smash the control machine.
Tyn
Posts: 932
Joined: Thu Nov 20, 2003 7:53 pm
Location: England
Contact:

Post by Tyn »

I'm wondering what the problem is. It must be that the XML->read() function is constantly returning true when it should return a false when it parses the entire XML document and thus end the loop. At least there is this workaround, the method just above seems the most sensible.
Post Reply