to print local xml file through NSData?
Posted
by senthilmuthu
on Stack Overflow
See other posts from Stack Overflow
or by senthilmuthu
Published on 2010-06-03T09:29:16Z
Indexed on
2010/06/03
10:24 UTC
Read the original article
Hit count: 377
iphone
|iphone-sdk
hi, i want to take some xml data from local path,and to parse,but when i use following code NSLog returns(content) different texts which is differed from xml file, how can i get exact xml data to check ,it consists correct xml data or not? any help please? when i parse , it returns nothing..i have saved the file as .xml and copied to local resource folder?
NSString *xmlFilePath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"samp.xml"];
NSString *xmlFileContents = [NSString stringWithContentsOfFile:xmlFilePath];
NSData *data = [NSData dataWithBytes:[xmlFileContents UTF8String] length:[xmlFileContents lengthOfBytesUsingEncoding: NSUTF8StringEncoding]];
NSString *content=[[NSString alloc]
initWithBytes:[data bytes]
length:[data length]
encoding:NSUTF8StringEncoding];
NSLog(@"%@",content);
© Stack Overflow or respective owner