XML Reader causing infinite loop

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
Klasker

XML Reader causing infinite loop

Post by Klasker »

I'm using an xml reader but it seems to be causing an infinite loop when it's done reading the document.
Here is the code:

Code: Select all

    while (xml && xml->read())
    {
        switch (xml->getNodeType())
        {
        case EXN_ELEMENT:
         /* .... commented out .... */
        } // end of case
      	
        case EXN_ELEMENT_END:
       {
          // </target>
          if (InTarget && stringw("target") == xml->getNodeName())
          {
                InTarget = false;
                spell->addTargetOption(targetOption);
          }
          else
          // </spell>
          if (!InTarget && InSpell && stringw("spell") == xml->getNodeName())
          {
                InSpell = false;
                AllSpells.push_back(spell);
          }
          else
          if (InSpells && !InSpell && stringw("spells") == xml->getNodeName())
          {
                InSpells = false;
          }
          break;
      }
      	
      } // end of switch
    }  // end of while
After reading the file through, xml->read() keeps returning true, and xml->getNodeType() returns EXN_ELEMENT_END, creating a never ending loop.
Btw, all three if statements evaluates to false at that point, so my code can hardly interfere there.

The xml file looks like this:

Code: Select all

<?xml version="1.0"?>

<spells>

<!-- Harm -->
<spell name="Harm" mana="16">

<target type="target" allowed="all">
<effect type="damage" amount="20" />
</target>

</spell>

</spells>
Can anyone help me here?
Guest

Post by Guest »

i noticed the same effect of an infinite loop, when changing the format of the xml file. try changing the format to UTF-16, thats the best format for the XMLReader (look at XMLWriter docu)
Post Reply