Strange behavior in XMLReader

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
d3jake
Posts: 198
Joined: Sat Mar 22, 2008 7:49 pm
Location: United States of America

Strange behavior in XMLReader

Post by d3jake »

I came across a strange behavior of the reader while working on my game, and decided to write a test case.

I noticed that XMLReader::run() behaves strangely. After hitting an opening node, calling run() will move the position of the reader to a node without a name, but it'll have the same attribute. Call it again, and it jumps to the next node in the XML file.

main.cpp:

Code: Select all

#include "irrlicht.h"
using namespace irr;
 
int main()
{
    io::IrrXMLReader *xml = io::createIrrXMLReader("test.xml");
 
    for(unsigned short int i = 0; i < 6; i++)
    {
        xml->read();
        printf("Node name: %s,  Attribute value: %s\n", xml->getNodeName(), xml->getAttributeValue("name"));
    }
 
    system("PAUSE");
 
}
XML_test.xml

Code: Select all

<first_node name="fred">
    <second_node>
    </second_node>
</first_node>
 
 
Output:

Code: Select all

Node name: first_node,  Attribute value: fred
Node name:
        ,  Attribute value: fred
Node name: second_node,  Attribute value: (null)
Node name:
        ,  Attribute value: (null)
Node name: second_node,  Attribute value: (null)
Node name: first_node,  Attribute value: (null)
Press any key to continue . . .
Is this a bug\problem, or am I doing things wrong? I can make a work-around for now, which would actually be fixing the problem correctly regardless of whatever's changed here. Ideas?
The Open Descent Foundation is always looking for programmers! http://www.odf-online.org
"I'll find out if what I deleted was vital here shortly..." -d3jake
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Strange behavior in XMLReader

Post by CuteAlien »

Which version are you using? I changed something in svn-trunk in that area about 5 months ago to drop the empty test-nodes between real nodes (before it handled them depending on the system and the number of whitespaces like tabs. Also preserving whitespace would have been the more correct solution, but it broke too much existing stuff to change that now).

So if you still use 1.7 your case might be fixed, if it's trunk... hm, then I have to check.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
d3jake
Posts: 198
Joined: Sat Mar 22, 2008 7:49 pm
Location: United States of America

Re: Strange behavior in XMLReader

Post by d3jake »

I can test with the trunk version, I simply have never used SVN so I don't know how to download the files.
The Open Descent Foundation is always looking for programmers! http://www.odf-online.org
"I'll find out if what I deleted was vital here shortly..." -d3jake
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Strange behavior in XMLReader

Post by CuteAlien »

You need an svn client - on Windows most people use tortoise svn. And then check-out using as server-address https://irrlicht.svn.sourceforge.net/sv ... icht/trunk (I'm not not on Windows right now, but tortoise-svn installs itself in a way you have all that stuff in the fileexplorer on right-click. On console would be: svn co https://irrlicht.svn.sourceforge.net/sv ... icht/trunk your_folder) . Once it's checked out you can get updates by running an svn update on your local folder.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
d3jake
Posts: 198
Joined: Sat Mar 22, 2008 7:49 pm
Location: United States of America

Re: Strange behavior in XMLReader

Post by d3jake »

Cool! Thanks! I'll let you know once I get to testing this.
The Open Descent Foundation is always looking for programmers! http://www.odf-online.org
"I'll find out if what I deleted was vital here shortly..." -d3jake
Post Reply