I am parsing some XML from an RSS feed (using NSXMLParser) for a blog and would like to display the data for e开发者_StackOverflowach post in a table cell. The XML looks like this:
<item>
    <title>Blog post 1</title>
    .
    .
</item>
<item>
    <title>Blog post 22</title>
    .
    .
</item>
How would I store this data so that it is available to my tableView:cellForRowAtIndexPath method?
I am thinking of creating a dictionary for each post item and appending these dictionaries to an NSMutableArray. This way I would be able to do something like,
cell.textLabel.text = [[mutableArray objectAtIndex: row] objectForKey: @"title"];
What do you reckon? I'm curious to know how you would approach this problem...
Thanks
This is the most common way of parsing and storing xml in objective-c utilizing nsxmlparser. Here's a snippet of my own code where I add the _locations dictionary to an array after reading the end element "locations" from the xml:
if ([elementName isEqualToString:@"location"]) {
            if ([[_location objectForKey:@"status"] isEqualToString: @"A"]) {
                [user.availableParking addObject:_location];
                [_location release];
                return;
            }
        }
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论