Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8037651
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T02:59:18+00:00 2026-06-05T02:59:18+00:00

EDIT: I figured it out, look towards the bottom half of this Before I

  • 0

EDIT: I figured it out, look towards the bottom half of this

Before I ask my question, I will state I have successfully used TBXML and RapidXML. Specifically Rapid has parsed this very same document successfully. I’m familiar with XML reading and assigning values.

That said, TinyXML and Cocos seems to be a good combination, as it compiles to android. I can go down the nodes ONCE, print out values, see where I am… the problem is this:

node = node->nextSibling();

Always returns false. I’ve learned that I can do this:

node->Parent()->NextSibling(); and this will give me the next sibling instead. But here’s a problem:

ParentNode->FirstChild() will return the first element of that tree. But if I call ParentNode->NextSibling(), for some reason it returns a pointer to the sibling, except it’s now one level higher on the tree.

This is going to make looping a semi nightmare.

I’m scouring http://grinninglizard.com/tinyxml2docs/classtinyxml2_1_1_x_m_l_node.html to find differences between using node, or element styles (eg: NextSiblingElement() ) but at best, I get one loop through with a failure, or just a crash.

This parser doesn’t work like the others, or I have the conventions wrong. I’ve placed cout’s everywhere to see where I am, and the initial runs seem fine. Specifically NextSibling is causing issues, and I think I just don’t know the tree structure that they “intend” to use.

This is my nested loop as of now:

            for( node = node->FirstChild(); node; node = node->NextSibling() )  {
            cout << endl << node->Parent()->Value();

            for( tempElement = node->FirstChildElement(); tempNode; tempElement = tempElement->NextSibling() ) {
                //assign inner values 
                }
           //take the inner values and assign them to an object
            }

So, while my code matches all of the suggestions for traversing sibling elements, it’s failing. I could use some help from someone who’s used this, as what I did in 30 minutes with every other system, is costing hours.

Also, I’m sure it’ll make more sense once “their way” is understood, but I can’t find one working example on the internet of doing this. Plenty of ones suggesting the sample code I have (not working).

For the most part, TinyXML does find nodes and values, and if you remember that to get the type, you have to use node->Parent()->Value(), then knowing where you are in a tree doesn’t seem too hard.

Just for kicks, here’s the load, which is working:

    if (doc.LoadFile(xmlFilePath.c_str()) == XML_SUCCESS)
{
    XMLNode *node = doc.RootElement();
    node = node->FirstChild(); //root 
 //....

Thanks for any assistance! Would be greatly appreciated, and perhaps the only TinyXML2 question with a working answer for future askers, at least at this point in time.


EDIT: I can’t answer yet, but I figured out:

For the love of… I hope I’m doing something wrong, if you’re doing this, pay attention to this pattern, it works (Probably same for TinyXML2, I’m guessing, just replace TiXmlNode with XMLNode):

note: node refers to the root.

Essentially, think of the NextSibling as a function on the parent, where it’s laying out “who’s next”.

Thanks for the visits so far. This traverses at least to 6 items (outer ones, yay!), then I’m sure the bug I’m having now is my own.

This should help somebody, if anyone else needs to traverse a tree dynamically.

       TiXmlNode * subNode = node->FirstChild();

    for(subNode = node ; subNode; subNode = subNode->Parent()->NextSibling()) 
    {
        subNode = subNode->FirstChild();
    cout << endl << "Parent " << subNode->Parent()->Value() << endl;

        for( tempNode = subNode; tempNode; tempNode = tempNode->Parent()->NextSibling() )
        {
            tempNode = tempNode->FirstChild();
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T02:59:20+00:00Added an answer on June 5, 2026 at 2:59 am

    The key is this line:
    Essentially, think of the NextSibling as a function on the parent, where it’s laying out “who’s next”.

    While every single XML Parser I’ve used before hand means “Sibling of current node”, TinyXML says “Sibling of the child”.

    It seems completely natural once I get used to it, but it still throws me for a crashing loop.

    Example code is in the bottom half of the post. This answer’s existence is explained in the comments of such.

    See you

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

EDIT I have finally figured out the problem i have been having on my
[Edit]: I figured out how to do this on my own. I posted my
EDIT: I figured it out from Bergi's answer in the end. Thanks Bergi. pubPrivExample
EDIT SO I figured out a fix. I replaced the while statement with an
Edit: I think I've figured out how to do the binary data part. Double
EDIT AGAIN ... I'm just a dummy and figured it out! EDIT: So, it
EDIT 07/14 As Bill Burgess mentionned in a comment of his answer, this question
Edit (updated question) I have a simple C program: // it is not important
EDIT: Figured it out! I was saving the absoluteString of the URL, and when
I'm trying to figure out the model binding in MVC3. Look at this example.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.