Google XML解析器
问题描述:
任何人都可以帮助我从解析的XML中获取格式化的日期。 我可以使用NSXML格式化程序对其进行格式化,但现在发现难以通过Google XMl分析程序使用它。在那里我能得到通过按键的值,但我需要在一个格式化的方式,Google XML解析器
return [NSDictionary dictionaryWithObjectsAndKeys:
[[[xmlItem elementsForName:@"title"] objectAtIndex:0] stringValue], @"title",
[[[xmlItem elementsForName:@"link"] objectAtIndex:0] stringValue], @"link",
[[[xmlItem elementsForName:@"pubDate"] objectAtIndex:0] stringValue], @"Date",
nil];
这里的pubdate的与HR也返回的XML,分,秒,我需要一个人的日期。
在此先感谢!
答
我得到了答案
//cell.textLabel.text = [item objectForKey:@"pubDate"];
NSString *yourXMLDate = [item objectForKey:@"pubDate"];
NSDateFormatter *inputFormatter = [[NSDateFormatter alloc] init];
[inputFormatter setDateFormat:@"E, d LLL yyyy HH:mm:ss Z"];
NSDate *inputDate = [inputFormatter dateFromString:yourXMLDate];
NSDateFormatter *outputFormatter = [[NSDateFormatter alloc] init];
[outputFormatter setDateFormat:@"MMM dd, HH:mm a"];
NSString *outputDate = [outputFormatter stringFromDate:inputDate];
cell.textLabel.text=outputDate;
凡是在10月12日上午12:30。无论在Xcode中使用的分析器这工作正常....
我认为你应该编辑你的问题是相关的。当你想知道如何执行日期/字符串转换时,“Google Xml Parser”是毫无意义的,对XML的任何引用都是毫无意义的。 – *foe
谢谢你*foe.My的问题是,GDataXMLNode(谷歌解析器)有任何日期格式化程序类似于NSXML日期格式化程序? – Sudhan