我试图解析一个 XML, 并将 URL 从 XML 的一个元素存储到一个 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"
)
我做错什么了?