我正在尝试解析 XML 并将 XML 的一个元素中的 URL 存储到 NSArray 中。到目前为止,这是我的代码:
NSURL *url = [NSURL URLWithString:@"http://www.316apps.com/LakesideDocs/podcasttrial.xml"];
NSData *xmlData = [[NSMutableData alloc] initWithContentsOfURL:url];
NSError *error;
GDataXMLDocument *doc = [[GDataXMLDocument alloc] initWithData:xmlData
options:0 error:&error];
NSArray *channels = [doc.rootElement elementsForName:@"channel"];
for (GDataXMLElement *channel in channels) {
NSArray *items = [channel elementsForName:@"item"];
for (GDataXMLElement *item in items) {
NSString *articlePoint = [item valueForChild:@"link"];
NSArray *linkarray = [[NSArray alloc] initWithObjects:articlePoint, nil];
NSLog(@"%@", linkarray);
}
}
对于 NSLog 我希望:
TabBarSample[40191:fb03] (
(
"http://domain.com/image1.jpg"
),
(
"http://domain.com/image2.jpg"
)
)
但我得到:
TabBarSample[40191:fb03] (
"http://domain.com/image1.jpg"
)
TabBarSample[40191:fb03] (
"http://domain.com/image2.jpg"
)
我究竟做错了什么?