我有一个这样的示例 XML:
<rss version="2.0">
<channel>
<title></title>
<link></link>
<description></description>
<item>
<title></title>
<link></link>
<description></description>
<pubDate></pubDate>
<guid></guid>
</item>
依此类推……我的 obj-c 语法如下所示:
NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
DDXMLDocument *ddDoc = [[DDXMLDocument alloc] initWithData:data options:0 error:&error];
NSArray *xmlItems = [ddDoc nodesForXPath:@"//item" error:&error]; // where ddDoc is your DDXMLDocument
NSMutableArray *returnArray = [[NSMutableArray alloc] initWithCapacity:[xmlItems count]];
for(DDXMLElement* itemElement in xmlItems)
{
ActiveActivity *activity = [[ActiveActivity alloc] init];
NSString *itemValueAsString = [[itemElement attributeForName:@"link"]stringValue];
[returnArray addObject:activity];
}
它没有返回任何价值,谁能告诉我为什么?