Note that there are some explanatory texts on larger screens.

plurals
  1. POhow can i parse xml string returned by asp.net webservice in objective c?
    primarykey
    data
    text
    <p>Hey can anyone please Help me Out.I am new in xcode (objective c) i m using asp.net web-service and simply i m returning 3 file name from that service in to my xcode project.now what i want to do is to parse the resulted web-service data which is in XML to simple string in xcode.</p> <p>my xml string is </p> <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://tempuri.org/"&gt; &lt;string&gt;Desert.jpg&lt;/string&gt; &lt;string&gt;Koala.jpg&lt;/string&gt; &lt;string&gt;Tulips.jpg&lt;/string&gt; &lt;/ArrayOfString&gt; </code></pre> <p>i have four class file in ma xcode project those are as follows</p> <p><strong>imagesavetestviewcontroller.m file</strong></p> <pre><code>// // ImageSaveTestViewController.m // ImageSaveTest // // Created by Kiichi Takeuchi on 4/4/10. // Copyright ObjectGraph LLC 2010. All rights reserved. // #import "ImageSaveTestViewController.h" @implementation ImageSaveTestViewController - (void)viewDidLoad { [super viewDidLoad]; NSString *urlString = @"http://192.168.3.106/local_storage/Webservice1.asmx/HelloWorld"; NSURL *url = [NSURL URLWithString:urlString]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; [request setHTTPMethod: @"POST"]; [request setValue:@"application/json" forHTTPHeaderField:@"Accept"]; [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"]; NSError *errorReturned = nil; NSURLResponse *theResponse =[[NSURLResponse alloc]init]; NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&amp;theResponse error:&amp;errorReturned]; if (errorReturned) { //...handle the error } NSString *retVal = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; **NSLog(@"%@", retVal);** //this is the retval which i want to convert in simple string.its containig that above xml file //...do something with the returned value NSLog(@"Downloading..."); // Get an image from the URL below id path = @"http://192.168.3.106/chmall/images/1.jpg"; NSURL *url1 = [NSURL URLWithString:path]; NSData *data11=[NSData dataWithContentsOfURL:url1]; UIImage *img1=[[UIImage alloc] initWithData:data11]; //UIImage *image = [[UIImage alloc] initWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@"192.168.3.106/chmall/images/1.jpg"]]]; NSLog(@"%f,%f",img1.size.width,img1.size.height); // Let's save the file into Document folder. // You can also change this to your desktop for testing. (e.g. /Users/kiichi/Desktop/) NSString *docDir = @"/Users/niketkapadia/Desktop"; //NSString *docDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]; // If you go to the folder below, you will find those pictures NSLog(@"%@",docDir); NSLog(@"saving png"); NSString *pngFilePath = [NSString stringWithFormat:@"%@/test.png",docDir]; NSData *data1 = [NSData dataWithData:UIImagePNGRepresentation(img1)]; [data1 writeToFile:pngFilePath atomically:YES]; NSLog(@"saving jpeg"); NSString *jpegFilePath = [NSString stringWithFormat:@"%@/test.jpeg",docDir]; NSData *data2 = [NSData dataWithData:UIImageJPEGRepresentation(img1, 1.0f)];//1.0f = 100% quality [data2 writeToFile:jpegFilePath atomically:YES]; NSLog(@"saving image done"); [img1 release]; } @end </code></pre> <p><strong>appdeleget.m file</strong></p> <pre><code>// ImageSaveTestAppDelegate.m // ImageSaveTest // // Created by Kiichi Takeuchi on 4/4/10. // Copyright ObjectGraph LLC 2010. All rights reserved. // #import "ImageSaveTestAppDelegate.h" #import "ImageSaveTestViewController.h" @implementation ImageSaveTestAppDelegate @synthesize window; @synthesize viewController; - (void)applicationDidFinishLaunching:(UIApplication *)application { // Override point for customization after app launch [window addSubview:viewController.view]; [window makeKeyAndVisible]; } - (void)dealloc { [viewController release]; [window release]; [super dealloc]; } @end </code></pre> <p><strong>delagte.h file</strong></p> <pre><code>// // ImageSaveTestAppDelegate.h // ImageSaveTest // // Created by Kiichi Takeuchi on 4/4/10. // Copyright ObjectGraph LLC 2010. All rights reserved. // #import &lt;UIKit/UIKit.h&gt; @class ImageSaveTestViewController; @interface ImageSaveTestAppDelegate : NSObject &lt;UIApplicationDelegate&gt; { UIWindow *window; ImageSaveTestViewController *viewController; } @property (nonatomic, retain) IBOutlet UIWindow *window; @property (nonatomic, retain) IBOutlet ImageSaveTestViewController *viewController; @end </code></pre> <p><strong>viewcontroller.h</strong></p> <pre><code>// // ImageSaveTestViewController.h // ImageSaveTest // // Created by Kiichi Takeuchi on 4/4/10. // Copyright ObjectGraph LLC 2010. All rights reserved. // #import &lt;UIKit/UIKit.h&gt; @interface ImageSaveTestViewController : UIViewController { } @end </code></pre>
    singulars
    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.
    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