我想弄清楚我是否可以以某种方式得到我的Wordpress RSS源的主体。即使我有我的wordpress设置来显示每篇文章的全文,当我在iPhone上解析它时,我只能得到摘要。分析RSS源的主体
这里是我的代码示例:
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict{
currentElement = [elementName copy];
if ([elementName isEqualToString:@"item"]) {
item = [[NSMutableDictionary alloc] init];
self.currentTitle = [[NSMutableString alloc] init];
self.currentSummary = [[NSMutableString alloc] init];
}
}
- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName{
if ([elementName isEqualToString:@"item"]) {
[item setObject:self.currentTitle forKey:@"title"];
[item setObject:self.currentSummary forKey:@"summary"];
[items addObject:[item copy]];
}
}
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string{
if ([currentElement isEqualToString:@"title"]) {
[self.currentTitle appendString:string];
} else if ([currentElement isEqualToString:@"description"]) {
[self.currentSummary appendString:string];
}
}
这已经从实例拼凑在一起。我已经通过将整个事物变成一个字符串并记录它来证实主体在那里。我仍然不知道我在世界上怎么知道要使用什么标签或标题。例如:“item”,“description”,“pubDate”,“title”。谁如何知道使用什么标签?请帮忙。
您打印了回复并检查了吗? –
您不应该在-foundCharacters方法中检查标记的条件。您应该使用键将所有数据保存在字典中。之后,您可以使用-valueForKey检索您的数据。 – Harsh