我在我的iphone应用程序中使用了TBXML。我有一个类似于下一个的xml:
<detail>
<title>My title</title>
<subs>
<sub>subCategory1</sub>
<sub>subCategory2</sub>
<sub>subCategory3</sub>
</subs>
</detail>我可以成功地获得标题,并且只有第一个子类别。我用来获取子类别的代码如下:
NSMuttableArray *divs = [[NSMuttableArray] initWithCapacity:3];
TBXMLElement *subsElement = [TBXML childElementNamed:@"subs" parentElement:currentElement];
TBXMLElement *subElement = [TBXML childElementNamed:@"sub" parentElement:subsElement];
do {
[divs addObject:[TBXML textForElement:subElement]];
NSLog(@"%@ , %@", @"Got one subCategory " , divs.lastObject);
} while ((subsElement = subsElement->nextSibling));发布于 2012-05-09 13:25:18
看起来您的where语句中有一个拼写错误。我相信你的意思是使用subElement而不是subsElement。所以你的代码应该是:
while ((subElement = subElement->nextSibling));https://stackoverflow.com/questions/10508526
复制相似问题