1

我有一个这样的 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.16.33.25/casa/admin/uploads/mathematic/Page001.html"/>
<pages id="1" name="" url="http://172.16.33.25/casa/admin/uploads/mathematic/Page002.html"/>
</chapters></books></subjects></class></user>

这里我需要数组中的 url 值,我正在使用NSXMLParser。我该如何解析这个。?

4

1 回答 1

0

尝试

-(void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict
{         
    if([elementName isEqualToString:@"pages"])
    {
        NSString *urlValue=[attributeDict valueForKey:@"url"];
        [arr addObject:urlValue];
    }
}
于 2013-03-27T08:30:04.890 回答