Tham khảo tài liệu 'phát triển ứng dụng cho iphone và ipad - part 38', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | Example 2 Term Extraction 339 NSLog connection didReceiveData Append the received data to our responseData property appendData data TermExtractViewController. m Now you need to implement connectionDidFinishLoading. The delegate calls this method when the connection has completed loading the requested data. In this method you convert the response data to a string clean up the connection and call the method to parse the XML Available for f download on Called when the connection has successfully received the complete response - void connectionDidFinishLoading NSURLConnection connection NSLog connectionDidFinishLoading Convert the data to a NSString responseString NSLog Response String string and log the response string NSString alloc initWithData encoding NSUTF8StringEncoding n responseString responseString release connection release self parseXML TermExtractViewController. m Finally you should implement the connection didFailWithError method. Here you will log that an error occurred. In a production application you would want to provide more robust error handling. Here is the implementation Available far download on Called when an error occurs in loading the response - void connection NSURLConnection connection didFailWithError NSError error NSLog @ connection didFailWithError NSLog @ @ error localizedDescription connection release TermExtractViewController. m 340 CHAPTER 11 INTEGRATING WITH WEB SERVICES Parsing the Response XML After you submit your request you will receive an XML response from the web service. The response will contain the most relevant words and phrases from the text that you sent into the service in order of relevance. The response that I received when I sent the declaration to the web service looked like this xml version ResultSet xmlns xsi http 2001 XMLSchema-instance xmlns urn yahoo cate xsi schemaLocation urn yahoo cate http ContentAnalysisService V1 .