Page 1 of 1

xml reader

Posted: Sat May 08, 2004 1:22 am
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?

Posted: Sat May 08, 2004 1:59 pm
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.

Posted: Sat May 08, 2004 2:22 pm
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.

Posted: Sat May 08, 2004 7:05 pm
by Unarekin
Make sure the XML file is saved as Unicode, and not ANSI.
Image

Posted: Sat May 08, 2004 7:55 pm
by Armen138
saving as unicode doesn't make any difference!(i think it was saved as unicode in the first place anyway)

workaround?

Posted: Fri Jul 09, 2004 3:41 pm
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";
}
}

Posted: Fri Jul 09, 2004 4:08 pm
by rogerdv
using a break tag doesnt works, at least under linux. I tried that long time ago

...

Posted: Mon Jul 12, 2004 8:42 pm
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";
}

...
}
}
}

Posted: Mon Jul 12, 2004 9:40 pm
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.