Write XML file to URL in xcode
I am trying to write data to XML file in xcode.
Say the XML file resides in http://www.abcd.com/sample.xml, i want to write data into that.
sample.xml
<Candidate>
<name>John Doe</name>
</Candidate>
I want to overwrite John Doe to something else.
All i know is i can pass NSURLString the URL &开发者_如何学编程; am very new to this technology, any help will be highly appreciated.
You are going to have to parse the xml in/out. For a test scenario you can do this:
NSString *theName = [NSString stringWithFormat:@"%@", nameField.text]; //I guess you know you should put a textfield there
NSMutableArray *overviewInfo = [[NSMutableArray alloc] init];
[overviewInfo addObject:theName];
[overviewInfo writeToURL:[NSURL URLWithString:@"http://username:password@abcd.com/sample.xml"]];
//username is your username on server
//password is your password on server
//example.com is the rest of the address you want to put that on
Hope that works for you.
精彩评论