我尝试使用 TBXML 解析以下字符串。
<panel><start><post_id>4</post_id><user_id>2</user_id><post>Hyder here</post><created_on>2012-01-09 06:36:59</created_on><likes>0</likes><noc>0</noc><status>A</status></start><start><post_id>3</post_id><user_id>2</user_id><post>Hello hyder here</post><created_on>2012-01-09 06:34:09</created_on><likes>0</likes><noc>0</noc><status>A</status></start><start><post_id>2</post_id><user_id>0</user_id><post>Hi, This is Syed Hyder....</post><created_on>2012-01-09 01:07:36</created_on><likes>0</likes><noc>0</noc><status>A</status></start><start><post_id>1</post_id><user_id>0</user_id><post>Hello, gaurav....How are you.</post><created_on>2012-01-09 01:05:11</created_on><likes>0</likes><noc>0</noc><status>A</status></start></panel>
我的代码: -
NSMutableArray *newArr = [[NSMutableArray alloc] init];//21
RXMLElement *rxml = [[RXMLElement alloc] initFromXMLString:response];
[rxml iterate:@"panel.start" with:^(RXMLElement *start) {
ModelPost *newPost = [[ModelPost alloc] init];
newPost.message = [NSString stringWithFormat:@"%@", [start child:@"post"]];
NSLog(@"Post = %@", [start child:@"post"]);
[newArr addObject:newPost];
}];
但我无法做到这一点或进入iterate loop
. 请通过示例代码、建议和教程帮助我解决这个问题。提前致谢....