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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:36:59+00:00 2026-06-03T05:36:59+00:00

Does anyone know why the file doesn’t format correctly on the line < taskinprogress>

  • 0

Does anyone know why the file doesn’t format correctly on the line “< taskinprogress>” its the 9th line. It puts “< project>” on the same line as “< taskinprogress> and I have no clue why. I want the “< project>” to be moved to the next line (without adding a \n character to a string).

<client_state>
    <platform>******PLATFORMNAME*******</platform>
    <OS_version>********OS VERSION*******</OS_version>
    <client_version>********client VERSION*******</client_version>
    <power_supply_connected>********POWER SUPPLY CONNECTED*******</power_supply_connected>
    <work_mode>********Work Mode*******</work_mode>
    <battery_level>********Battery Level*******</battery_level>
    <last_update>********Last Update*******</last_update>
    <task_in_progress>********task_in_progress*******<project>********Project*******</project>
        <application>********Application*******</application>
        <xml_file>********xml_file*******</xml_file>
        <task_id>********task_id*******</task_id>
        <create_time>********create_time*******</create_time>
        <receive_time>********receive_time*******</receive_time>
        <input>********input*******</input>
    </task_in_progress>
</client_state>

The following is my code that declares all of the nodes and elements.

#import <Foundation/Foundation.h>

int main (int argc, const char * argv[]) {

    NSXMLElement *client_state = [[NSXMLElement alloc] initWithName:@"client_state"];

    NSXMLElement *platform = [[NSXMLElement alloc] initWithName:@"platform"];
    [platform setStringValue:@"******PLATFORMNAME*******"];
    [client_state addChild:platform];
    [platform release];

    NSXMLElement *OS_version = [[NSXMLElement alloc] initWithName:@"OS_version"];
    [OS_version setStringValue:@"********OS VERSION*******"];
    [client_state addChild:OS_version];
    [OS_version release];

    NSXMLElement *client_version = [[NSXMLElement alloc] initWithName:@"client_version"];
    [client_version setStringValue:@"********client VERSION*******"];
    [client_state addChild:client_version];
    [client_version release];

    NSXMLElement *power_supply_connected = [[NSXMLElement alloc] initWithName:@"power_supply_connected"];
    [power_supply_connected setStringValue:@"********POWER SUPPLY CONNECTED*******"];
    [client_state addChild:power_supply_connected];
    [power_supply_connected release];

    NSXMLElement *work_mode = [[NSXMLElement alloc] initWithName:@"work_mode"];
    [work_mode setStringValue:@"********Work Mode*******"];
    [client_state addChild:work_mode];
    [work_mode release];

    NSXMLElement *battery_level = [[NSXMLElement alloc] initWithName:@"battery_level"];
    [battery_level setStringValue:@"********Battery Level*******"];
    [client_state addChild:battery_level];
    [battery_level release];

    NSXMLElement *last_update = [[NSXMLElement alloc] initWithName:@"last_update"];
    [last_update setStringValue:@"********Last Update*******"];
    [client_state addChild:last_update];
    [last_update release];

    //if(task in progress)

    NSXMLElement *task_in_progress = [[NSXMLElement alloc] initWithName:@"task_in_progress"];
    [task_in_progress setStringValue:@"********task_in_progress*******"];
    [client_state addChild:task_in_progress];
    [task_in_progress retain];
    [task_in_progress release];

    //start adding to inner task in progress

    NSXMLElement *project = [[NSXMLElement alloc] initWithName:@"project"];
    [project setStringValue:@"********Project*******"];
    [task_in_progress addChild:project];
    [project release];

    NSXMLElement *application = [[NSXMLElement alloc] initWithName:@"application"];
    [application setStringValue:@"********Application*******"];
    [task_in_progress addChild:application];
    [application release];

    NSXMLElement *xml_file = [[NSXMLElement alloc] initWithName:@"xml_file"];
    [xml_file setStringValue:@"********xml_file*******"];
    [task_in_progress addChild:xml_file];
    [xml_file release];

    NSXMLElement *task_id = [[NSXMLElement alloc] initWithName:@"task_id"];
    [task_id setStringValue:@"********task_id*******"];
    [task_in_progress addChild:task_id];
    [task_id release];

     NSXMLElement *create_time = [[NSXMLElement alloc] initWithName:@"create_time"];
     [create_time setStringValue:@"********create_time*******"];
     [task_in_progress addChild:create_time];
     [create_time release];

     NSXMLElement *receive_time = [[NSXMLElement alloc] initWithName:@"receive_time"];
     [receive_time setStringValue:@"********receive_time*******"];
     [task_in_progress addChild:receive_time];
     [receive_time release];

    NSXMLElement *input = [[NSXMLElement alloc] initWithName:@"input"];
    [input setStringValue:@"********input*******"];
    [task_in_progress addChild:input];
    [input release];

    [task_in_progress release];

    NSXMLDocument *xmlRequest = [NSXMLDocument documentWithRootElement:client_state];
    [client_state release];
    NSLog(@"XML Document\n%@", xmlRequest);
     NSData *xmlData = [xmlRequest XMLDataWithOptions:NSXMLNodePrettyPrint];
    [xmlData writeToFile:@"client_state.xml" atomically:YES];
    [xmlRequest release];
    return 0;
}
  • 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-03T05:37:00+00:00Added an answer on June 3, 2026 at 5:37 am

    Silly mistake on my part. I figured it out. If anyone else is reading this and curious, all root type nodes should NOT also have a value. I am using “< task_in_progress” as a node, so I had to remove the line follow its declaration:

    //delete this:  Its a root, not a node w/ a value
     [task_in_progress setStringValue:@"********task_in_progress*******"];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone know why loading a KML file into my sencha touch google map
Does anyone know how to write to a text file in Android using a
Does anyone know of any methods to create a file upload progress bar in
Does anyone know how to write to an excel file (.xls) via OLEDB in
Does anyone know of a method to determine when a file copy completes in
Does anyone know how to read a x.properties file in Maven. I know there
Does anyone know how to import a mysql sql file into microsoft visio 2007,
does anyone know how to check if a file or directory is either a
Does anyone know what the difference is between adding an appropriate JAR-file (eg. Apache
Does anyone know how to uncompress the contents of a gzip file that i

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.