开发者

IPAD xml parsing with attributes deal

<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");
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜