0
我是iPhone開發新手,我試圖解析此鏈接並將其放在我的桌面視圖上,但是當我的桌面視圖顯示時,標題不顯示在行中。我在這裏做錯了什麼?iPhone XML解析問題
- (void)viewDidLoad {
[super viewDidLoad];
self.title = @"RSS Feeds";
rssList = [[NSMutableArray alloc] initWithCapacity:1];
NSString *URLString = [[NSString alloc]initWithFormat:@"http://www.rpg.net/index.xml"];
NSLog(@"%@",URLString);
NSURL *xmlURL = [NSURL URLWithString:URLString];
NSXMLParser *firstParser = [[NSXMLParser alloc] initWithContentsOfURL:xmlURL];
[firstParser setDelegate:self];
[firstParser parse];
[URLString release];
}
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName attributes:(NSDictionary *)attributeDict {
if ([elementName compare:@"item"] == NSOrderedSame) {
[rssList addObject:[[NSDictionary alloc] initWithObjectsAndKeys:
[attributeDict objectForKey:@"title"],@"title",
[attributeDict objectForKey:@"link"],@"link",
nil]];
}
}
您是否實現了'UITableViewDataSource'協議以返回格式爲rssList'中的元素的單元? – darvids0n
首先檢查解析是否正常工作 – ajay