我有一个XML文件,
<?xml version="1.0" standalone="yes"?>
<user id="1" name=""><class id="1" name=""><subjects id="1" name=""><books id="1" name="">
<chapters id="1" name="">
<pages id="0" name="" url="http://172.11.133.12/uploads/mathematic/Page001.html"/>
<pages id="1" name="" url="http://172.11.133.12/uploads/mathematic/Page002.html"/>
</chapters>
<chapters id="2" name="">
<pages id="0" name="" url="http://172.11.133.12/uploads/mathematic1/Page001.html"/>
<pages id="1" name="" url="http://172.11.133.12/uploads/mathematic1/Page002.html"/>
</chapters>
</books></subjects></class></user>
这里我使用NSXML Parser解析了这一点,一切正常,这里我需要在UItableview中显示章节ID,当用户选择任何章节时,应该在Webview中打开URL。我在TableView单元格中显示了所有章节名称,我想知道如何为每个章节标记获取相应的URL值。
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName
namespaceURI:(NSString *)namespaceURI
qualifiedName:(NSString *)qName
attributes:(NSDictionary *)attributeDict
{
currentElement = [elementName copy];
if ([elementName isEqualToString:@"chapters"]) {
flag = 0;
chapID = [attributeDict valueForKey:@"id"];
}
if ([elementName isEqualToString:@"pages"]){
urlValue = [attributeDict valueForKey:@"url"];
}
这里我需要在章节中存储相应的Pages标签...请指导我..