This code makes no sense.
You create a NSData object with a path to a file then you turn around and reassign to the path var a string representing a chunk of XML. It's very muddled and likely to cause errors. Don't reuse variables this way.
In any case, to encode data to a string you use NSString's:
- (id)initWithData:(NSData *)data encoding:(NSStringEncoding)encoding
Then just insert that string wherever you want it.
Edit:
Hello, sorry for i dont know how to
use this - (id)initWithData:(NSData
*)data encoding:(NSStringEncoding)encoding in
my code.
Like so: (Sorry about the formatting Stackoverflow's editor seems to be on blink today)
NSData *myData = [NSData dataWithContentsOfFile:pathDoc];
NSString *myDataString = [[NSString alloc] initWithData:myData encoding:NSUnicodeStringEncoding];
NSString *formatString = @"<size>%d</size><type>%d</type><cdate>%@</cdate><file>%c</file><fname>File</fname><data>%@</data>";
pathDoc = [NSString stringWithFormat:formatString,fileSizeVal,filetype,creationDate,myDataString];
The NSUnicodeStringEncoding
is one of several constants defining a variety of string encodings. See the NSString class reference. Which one you use depends on what your server expects.
Good luck.