Re: How do you append the data to the URL while POSTING?
Re: How do you append the data to the URL while POSTING?
- Subject: Re: How do you append the data to the URL while POSTING?
- From: Conor Dearden <email@hidden>
- Date: Sat, 04 Nov 2006 17:44:35 +0100
> 1) How do you append the data to the URL while POSTING?
>
> 2)How do you receive a response Data from the server?
>
> 3) I have seen a code to parse an XML.
> But I don't see any to create an XML. I need to know how to create an XML
> file .
The following should give you a place where to start digging into the Cocoa
documentation: (Written in Mail could have typos).
NSMutableURLRequest* postRequest = [NSMutableURLRequest requestWithURL:
[NSURL URLWithString:@"http://www.YourServer.com/post.php"]];
[postRequest setHTTPMethod: @"POST"];
NSString *bodyOfPost = @"language=Cocoa&User=Me";
[postRequest setHTTPBody: [bodyOfPost dataUsingEncoding:
NSISOLatin1StringEncoding]];
NSURLConnection *theConnection = [[[NSURLConnection alloc]
initWithRequest: postRequest delegate:self] autorelease];
// Send the post and get a response
// This can be done asynchronous but that is more complicated
NSString *XMLResponse = [[[NSString alloc] initWithData:[NSURLConnection
sendSynchronousRequest: postRequest returningResponse:nil error:nil]
encoding:NSISOLatin1StringEncoding] autorelease];
// Use NSXMLDocument to parse the data or do it by hand with NSScanner
Regards,
Conor
http://www.bruji.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden