when i try to write to an xml file it doesn't seem to have changed
I put the xml file into the main bundle (in the resources folder) and i can read from it fine.
i just can't write to it
this is what i'm doing to write to it... i know there's something i'm doing wrong, i just can't see what it is...
in debug mode i see that root is being added to correctly, and the new element is being added to it...
it's just not printing out to it...
I put the xml file into the main bundle (in the resources folder) and i can read from it fine.
i just can't write to it
this is what i'm doing to write to it... i know there's something i'm doing wrong, i just can't see what it is...
Code:
NSBundle *bundle = [NSBundle mainBundle];
NSString* fileName = [bundle pathForResource: @"theXMLFile" ofType: @"xml"];
if(!fileName) return;
NSURL* url = [NSURL fileURLWithPath: fileName];
NSXMLDocument* document = [[NSXMLDocument alloc] initWithContentsOfURL: url options: NSXMLDocumentTidyXML error: nil];
NSXMLElement* root = [document rootElement];
NSXMLElement* node = (NSXMLElement*)[NSXMLNode elementWithName: @"aTestElement"];
[root addChild: node];
NSData *xmlData = [document XMLDataWithOptions: NSXMLNodePrettyPrint];
if(![xmlData writeToFile: fileName atomically: YES]) {
NSBeep();
NSRunAlertPanel(@"Save Report Builder Settings Error", @"Could not save the Report Builder Settings", @"OK", NULL, NULL);
}
NSRunAlertPanel(@"Adding New Preset", @"New Preset Added", @"OK", NULL, NULL);
it's just not printing out to it...