0

My issue is to display file coming from a XML Response on the iPhone using UIDocumentInteraction Controller. I am unable to convert this file.The guy who is doing web-service is saying that its a binary data. Please refer to the following XML Response

< NewDataSet>
< Table diffgr:id="Table1" msdata:rowOrder="0">
< FILE >
UEsDBBQABgAIAAAAIQDd/JU3ZgEAACAFAAATAAgCW0NvbnRlbnRfVHlwZXNdLnhtbCCiBAIooAACAAAAAAAAAAAAAA < /FILE >
< FILENAME >New Word Doucment < / FILENAME >
< FILETYPE >doc< /FILETYPE >
< RESULT>SUCCESS< /RESULT >
< /Table >
< /NewDataSet >

I have trimmed the FILE tag.. it will be really very huge

I have parsed the xml and stored the content of < FILE > tag into "filePath" I am doing the following
const char *utfString = [filePath UTF8String];
//filepath contains the string for FILE
NSData *myData = [NSData dataWithBytes: utfString length: strlen(utfString)];

//NSData *myData = [Base64 decode:filePath];
NSString *docDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
//       
NSString *file = [NSString stringWithFormat:@"%@.%@", fileName,fileType];
NSString *newPath = [docDir stringByAppendingPathComponent:file];
[myData writeToFile:newPath atomically:YES];
myData=nil;

Please let me know how to parse this XML and save the file or just display it.

yuji
  • 16,695
  • 4
  • 63
  • 64
  • Have a look at this [answer](http://stackoverflow.com/questions/6472634/iphone-soap-connection-ideas/6473624#6473624). – Teodor Kostov Jul 27 '11 at 14:58
  • I have found the solution for this Problem... We may have to do base 64 decoding for that and I have am using the base 64 decoding options provided [here](http://www.cocoadev.com/index.pl?BaseSixtyFour) – Ashwin Nooli Jul 28 '11 at 12:39

1 Answers1

0

The filestring should be decoded using base64 decoding. I have used the code provided in the following url Base 64 Decoding