irrXML generating EXN_ELEMENT_END twice(easy fix)

Post your questions, suggestions and experiences regarding game design, integration of external libraries here. For irrEdit, irrXML and irrKlang, see the
ambiera forums
Post Reply
Legion
Posts: 15
Joined: Sun Oct 29, 2006 5:03 pm

irrXML generating EXN_ELEMENT_END twice(easy fix)

Post by Legion »

EDIT:
There was supposedly an API function called isEmptyElement(),
I didn't notice it, not enough coffee i guess,
but the rootelement generating EXN_ELEMENT_END twice is still a bug!

Code: Select all

<?xml version="1.0"?>
<XML>
</XML>

In this example, with the following code:

Code: Select all

static int	begs = 0;
static int	ends = 0;

while(xmlreader->read())
{

	switch(xmlreader->getNodeType())
	{
		case io::EXN_ELEMENT:
					begs++;
					break;
		case io::EXN_ELEMENT_END:
					ends++;
					break;
	}
}

You would assume the result would be:
begs == 1
ends == 1

But in reality it's
begs == 1
ends == 2

This is wrong, the rootelement of the XML file will return EXN_ELEMENT_END twice!

The reason is occur is because how data is parsed.
parseCurrentNode() is called from read(), however read will return
true as long as *P != 0, so there will always be one extra call to read
that is excessive.

The following could be added after parseClosingXMLElement() is called from parseCurrentNode(), so that whites are always skipped after a closing tag.

Code: Select all

// more forward until '<' found
while(*P != L'<' && *P)
	++P;
/Legion
Post Reply