Parse Protected XML in XCODE

smyyy

New Member
I was wondering if anyone could help to parse protected XML file in XCODE.Here is what I got, but I don't know how to mix up these things since I'm pretty new in XCODE.Connection with Authentication\[code\] -(void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge: (NSURLAuthenticationChallenge *)challenge{ if ([challenge previousFailureCount] == 0) { NSURLCredential *newCredential; newCredential=[NSURLCredential credentialWithUser:@"myusername" password:@"mypassword" persistence:NSURLCredentialPersistenceNone]; [[challenge sender] useCredential:newCredential forAuthenticationChallenge:challenge];} else { [[challenge sender] cancelAuthenticationChallenge:challenge]; NSLog(@"Bad Username Or Password"); UIAlertView* aler = [[UIAlertView alloc] initWithTitle:@"Authentication Error" message:@"Unable to connect to the server, Please Contact The WebMaster." delegate:nil cancelButtonTitle:@"Close" otherButtonTitles:nil]; [aler show]; [aler release]; } }\[/code\]Parse Code\[code\] -(void)doParse{[SongArray removeAllObjects];//NEED TO GET XML DOCUMENT INTO NSData OBJECT!!!NSURL *theURL = [[NSURL alloc] initWithString:@"myurl"];// create and init NSXMLParser objectNSXMLParser *nsXmlParser = [[NSXMLParser alloc] initWithContentsOfURL:theURL];// create and init our delegateXMLParser *parser = [[XMLParser alloc] initXMLParser];//set delegate[nsXmlParser setDelegate:parser];//parsing...BOOL success = [nsXmlParser parse];// test the resultif (success) { NSLog(@"success"); SongArray = [parser getPeople]; [self.SongDescription reloadData];} else { UIAlertView* aler = [[UIAlertView alloc] initWithTitle:@"Server Error" message:@"Unable To Read The Song Information, You May Keep Listening To The Radio Without Song Information" delegate:nil cancelButtonTitle:@"Close" otherButtonTitles:nil]; [aler show]; [aler release]; NSLog(@"fail");} }\[/code\]
 
Back
Top