Menu

#45 child element count

open
nobody
None
5
2006-04-03
2006-04-03
msteiger
No

It would be great if you could tell how much children a
node has. I need this function a few times in my
project, so I always add it manually to tinyXML. It
might be useful for other people too, so I post it here :

int TiXmlNode::ChildElementCount(const char *value) const
{
int count = 0;

const TiXmlElement* e = FirstChildElement(value);

while (e)
{
e = e->NextSiblingElement(value);
count++;
}

return count;
}

int TiXmlNode::ChildElementCount() const
{
int count = 0;

const TiXmlElement* e = FirstChildElement();

while (e)
{
e = e->NextSiblingElement();
count++;
}

return count;
}

Would be cool, if you can include that snippet into the
next release..

Cheers :-)

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.