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 3243982
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T18:29:50+00:00 2026-05-17T18:29:50+00:00

I am having an issue with the following code. It uses the Mini-XML library

  • 0

I am having an issue with the following code.

It uses the Mini-XML library to extract elements from an xml file.

It compiles and runs fine, except that it is unable to get the last “radius element,” returning NULL instead (it crashes if I don’t check to see if subnode is not NULL).

//Start loading <ssys> elements
mxml_node_t *node; //temporary node to save
mxml_node_t *subnode; //temporary subnode to save
mxml_node_t *subnode2; //another temporary subnode to save
const char* name_tmp; //Temporary string for names of ssys
//Load first ssys
node = mxmlFindElement(Systems_elem, tree, "ssys", NULL, NULL, MXML_DESCEND);
cout << "Node 1 pointer: " << node<<endl<<endl;
//Start loading the rest of the ssys elements (but fail if first element is NULL)
int i = 1;
do {
    //Load node into vector of pointers
    ssys_elem.push_back(node);
    //Get name attribute
    name_tmp = mxmlElementGetAttr(node, "name");
    ssys_name.push_back(name_tmp);
    //load next ssys
    node = mxmlFindElement(node, tree, "ssys", NULL, NULL, MXML_NO_DESCEND);
    cout << "Node: " << node<<endl<<endl;
    cout<<"Name: " <<name_tmp<<endl<<endl;
    //Descend to radius element
    subnode = mxmlFindElement(node, tree, "radius", NULL, NULL, MXML_DESCEND);
    //
    if(subnode != NULL){
        cout <<subnode->child->value.text.string<<endl<<endl; <--Trouble Here
    }
   i++;
}
while (node != NULL);

}

Here is a piece of the XML file in question:

 <ssys name="Zylex">
  <general>
   <radius>3500.000000</radius> <-- I am trying to get "3500.000000"
   <stars>400</stars>
   <asteroids>0</asteroids>
   <interference>300.000000</interference>
   <nebula volatility="0.000000">250.000000</nebula>
  </general>
  <pos>
   <x>438.000000</x>
   <y>-34.000000</y>
  </pos>
  <assets/>
  <jumps>
   <jump target="Arcanis">
    <pos x="-3418.937501" y="-748.910119"/>
    <radius>200.000000</radius>
    <flags>
     <autopos/>
    </flags>
   </jump>
   <jump target="Doeston">
    <pos x="2991.156265" y="1817.411401"/>
    <radius>200.000000</radius>
    <flags>
     <autopos/>
    </flags>
   </jump>
  </jumps>
 </ssys>
</Systems>

What’s the problem with this code?

  • 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-05-17T18:29:50+00:00Added an answer on May 17, 2026 at 6:29 pm

    Well I’m guessing you’re talking about Mini-XML, which I honestly have no experience with. What I do see is that you’re iterator is one step ahead of your name. I think you want something more like:

    node = mxmlFindElement(Systems_elem, tree, "ssys", NULL, NULL, MXML_DESCEND);
    while (node) {
        ssys_elem.push_back(node);
        name_tmp = mxmlElementGetAttr(node, "name");
        ssys_name.push_back(name_tmp);
    
        cout << "Node: " << node << endl << endl;
        if (name_tmp) {
            cout << "Name: " << name_tmp << endl << endl;
        }
    
        // Descend to radius element
        subnode = mxmlFindElement(node, tree, "radius", NULL, NULL, MXML_DESCEND);
        if (subnode != NULL){
            cout << subnode->child->value.text.string << endl << endl; <--Trouble Here
        }
    
        // iterate at the end!
        node = mxmlFindElement(node, tree, "ssys", NULL, NULL, MXML_NO_DESCEND);
    }
    

    And in general never trust that you have well-formed XML. Always check for NULL even when you think there should be a child. Hope that helps.

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

Sidebar

Related Questions

I'm having an issue with the following code: private void DataPortal_Fetch(TaskCriteria criteria) { using
Ok. I'm having an issue with the following bit of code: StreamReader arrComputer =
Having a bit of an issue please see the following code: window.onload = function
I have the following application which replicates an issue I'm having in a larger
I'm having an issue with a query that currently uses LEFT JOIN weblog_data AS
A client is having an issue running java2ws on some of their code, which
Using Internet Explorer (don't appear to have an issue in FireFox) the following code
I'm having an issue with my regex. I want to capture <% some stuff
I'm having an issue with a Flash/Flex erroring in Firefox but not IE. I
I’m having an issue where a drop down list in IE 6/7 is behaving

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.