0
我想解析这个源:http://missing.amberalertnederland.nl/nl/index.rss与TBXMLParser。为此目的,即时通讯使用此代码:TBXML解析器解析一个RSS源
- (void)loadRecords:(NSString *)records {
NSString *someXML = @"http://missing.amberalertnederland.nl/nl/index.rss";
TBXML *tbxml = [[TBXML tbxmlWithURL:[NSURL URLWithString:someXML]] retain];
records = [NSMutableArray array];
[records retain];
if (tbxml.rootXMLElement)
[self traverseElement:tbxml.rootXMLElement];
[tbxml release];
}
- (void) traverseElement:(TBXMLElement *)element {
do {
if (element->firstChild)
[self traverseElement:element->firstChild];
if ([[TBXML elementName:element] isEqualToString:@"item"]) {
TBXMLElement *title = [TBXML childElementNamed:@"title" parentElement:element];
TBXMLElement *link = [TBXML childElementNamed:@"link" parentElement:element];
TBXMLElement *description = [TBXML childElementNamed:@"description" parentElement:element];
[records addObject:[NSArray arrayWithObjects:
[TBXML textForElement:title],
[TBXML textForElement:link],
[TBXML textForElement:description],nil]];
}
} while ((element = element->nextSibling));
NSLog(@"%@", records);
}
但是,记录数组只返回(空)值。
任何有关如何使用TBXML(我认为我做得对)的指南也将受到欢迎。我从来没有使用TBXML
只考虑修改现有的问题。编辑完成后,它会再次出现在首页。 –