Possible Duplicate:
NSString to Nsdata
I am trying to use GDataXML to parse through XML as I receive it somewhat on the fly from a web service call. The tutorial I have been using, illustrates the proper procedure for reading from an xml file and then parsing it. I have all of the necessary xml data in a string, can't I just use a string?
Heres the code as the tutorial shows it:
NSData *xmlData = [[NSMutableData alloc] initWithContentsOfFile:filePath];
NSError *error;
GDataXMLDocument *doc = [[GDataXMLDocument alloc] initWithData:xmlData
options:0 error:&error];
NSLog(@"%@", doc.rootElement);
And then here is what I thought I could do:
NSData *xmlData = [[NSMutableData alloc] initWithString:resultString];
NSError *error;
GDataXMLDocument *doc = [[GDataXMLDocument alloc] initWithData:xmlData
options:0 error:&error];
NSLog(@"%@", doc.rootElement);
But I am being told that un unrecognized selector is being sent. Basically its breaking on my xmlData object init. Can I not init an NSData object with a String? Do I have to take the contents of the String and write it to a file in the bundle and then call the file and read from it?
Any thoughts?
Thanks!