6

I think problem is with wrong using function or something else.

This part of code is working but the result isn't well.

TiXmlElement* e = hDoc.FirstChildElement().Element(); // think problem is there
while (e)
{
    e = e->NextSiblingElement();  //or may be there
    count++;
}

The result of count is 1.


Xml file is:

<doc>
   <state> ... </state>
   <state> ... </state>
   ...
</doc>

Can't find work example.

Max
  • 115
  • 2
  • 8

1 Answers1

10

if you read the documentation you can find the following example (which seems neater than your approach):

for( child = parent->FirstChild(); child; child = child->NextSibling() )
    count++;

But you are probably only trying to count the states so I would suggest:

for( child = parent->FirstChild("state"); child; child = child->NextSibling("state") )

You probably also want something like this:

TiXmlElement *parent = hDoc.RootElement();
Underdetermined
  • 419
  • 4
  • 9