嗨,大家好,我有一点奇怪的问题。我正在使用一个简单的XML到NSDictionary转换器 http://troybrant.net/blog/2010/09/simple-xml-to-nsdictionary-converter/ 但如果打印NSDictionary,我可以看到节点的文本值,但如果我将它存储在plist中,文本节点将不会有任何字符串值。见附加图像。 XML到NSdictionary plist
这里是plist截图。
这里是代码
NSURL * URL = [[NSURL alloc]initWithString:@"rss feed link "];
NSData * data = [[NSData alloc] initWithContentsOfURL:URL];
NSString *testXMLString = [[NSString alloc]initWithData:data encoding:NSUTF8StringEncoding];
// Parse the XML into a dictionary
NSError *parseError = nil;
NSDictionary *xmlDictionary = [XMLReader dictionaryForXMLString:testXMLString error:&parseError];
NSString * filepath = [self dataFilePathwithFilename:[NSString stringWithFormat:@"TEST.plist"]];
[xmlDictionary writeToFile:filepath atomically:YES];
// Print the dictionary
NSLog(@"%@", xmlDictionary);
哎迪帕克更换
我应该怎样解析到NSdicntionary之前从的NSString * testXMLString这些新行字符。 – Amrit
@Amrit更新了我的答案。 –
嘿谢谢迪帕克 – Amrit