<category 开发者_JAVA百科name="Local">
…
…
…
<category name="business">
…
…
…
<category name="politics">
…
…
…
This is my xml file, I'm not sure how to deal with attribute i am using NSXMLParser. My question is how to deal with above attributes in NSXMLParser. Please help me. Thanks in advance.
You should have a look at parser:didStartElement:namespaceURI:qualifiedName:attributes:. The names are then in the attributes dictionary.
Edit:
If the following doesn't help you, you should read some introduction stuff.
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName attributes:(NSDictionary *)attributeDict {
if ([[attributeDict objectForKey: @"name"] isEqualToString: @"Local"]) {
NSLog(@"found category with name Local");
}
}
精彩评论