Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to update node values and add nodes in xml file?
    primarykey
    data
    text
    <p>i am new iphone developer,in my application i can read data from xml code to read xml:: -(NSString *)readxmlFile:(NSString *)fileName ElementName:(NSString *)Element Poisson:(NSInteger *)Index { xmlelement = Element; NSString *filePath = [[NSBundle mainBundle] pathForResource:fileName ofType:@"xml"]; </p> <pre><code>NSData *myData = [NSData dataWithContentsOfFile:filePath]; NSString *str,*docStr; if (myData) { str = [[NSString alloc] initWithData:myData encoding:NSASCIIStringEncoding]; } NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; // the path to write file NSString *appFile = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.xml",fileName]]; NSError *error = nil; BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:appFile]; NSData *myData1 = [NSData dataWithContentsOfFile:appFile]; if(fileExists) { NSLog(@"file exist in document"); if (myData1) { docStr = [[NSString alloc] initWithData:myData1 encoding:NSASCIIStringEncoding]; xmlparser=[[NSXMLParser alloc] initWithData: myData1]; [xmlparser setDelegate:self]; [xmlparser parse]; NSLog(@"Data&gt;&gt;%@",xmlData); } } else { NSLog(@"file does not exist"); xmlparser=[[NSXMLParser alloc] initWithData: myData1]; [xmlparser setDelegate:self]; [xmlparser parse]; NSLog(@"Data&gt;&gt;%@",xmlData); BOOL success = [str writeToFile:appFile atomically:YES encoding:NSUTF8StringEncoding error:&amp;error]; if (!success) { NSLog(@"Error: %@", [error userInfo]); } else { NSLog(@"File write is successful"); } NSData *myData1 = [NSData dataWithContentsOfFile:appFile]; if (myData1) { docStr = [[NSString alloc] initWithData:myData1 encoding:NSASCIIStringEncoding]; } } return [xmlData objectAtIndex:Index];//pasre data from xml based on node name and save in xmlData </code></pre> <p>} but unable to write xml(add nodes and update node values) ,please guide to me how to add nodes and update node values in xml file. Thanks in advance</p>
    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