Note that there are some explanatory texts on larger screens.

plurals
  1. PONSXMLDocument writing to .xml
    primarykey
    data
    text
    <p>Does anyone know why the file doesn't format correctly on the line "&lt; taskinprogress>" its the 9th line. It puts "&lt; project>" on the same line as "&lt; taskinprogress> and I have no clue why. I want the "&lt; project>" to be moved to the next line (without adding a \n character to a string).</p> <pre><code>&lt;client_state&gt; &lt;platform&gt;******PLATFORMNAME*******&lt;/platform&gt; &lt;OS_version&gt;********OS VERSION*******&lt;/OS_version&gt; &lt;client_version&gt;********client VERSION*******&lt;/client_version&gt; &lt;power_supply_connected&gt;********POWER SUPPLY CONNECTED*******&lt;/power_supply_connected&gt; &lt;work_mode&gt;********Work Mode*******&lt;/work_mode&gt; &lt;battery_level&gt;********Battery Level*******&lt;/battery_level&gt; &lt;last_update&gt;********Last Update*******&lt;/last_update&gt; &lt;task_in_progress&gt;********task_in_progress*******&lt;project&gt;********Project*******&lt;/project&gt; &lt;application&gt;********Application*******&lt;/application&gt; &lt;xml_file&gt;********xml_file*******&lt;/xml_file&gt; &lt;task_id&gt;********task_id*******&lt;/task_id&gt; &lt;create_time&gt;********create_time*******&lt;/create_time&gt; &lt;receive_time&gt;********receive_time*******&lt;/receive_time&gt; &lt;input&gt;********input*******&lt;/input&gt; &lt;/task_in_progress&gt; &lt;/client_state&gt; </code></pre> <p>The following is my code that declares all of the nodes and elements.</p> <pre><code>#import &lt;Foundation/Foundation.h&gt; 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; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload