Hi all,
I have a little question regarding xml data and arrays.
So i'm parsing an xml file and i'm trying to add the parsed data into an array which i can later use as the cell data for a table view.
i keep getting the last node from the xml and i don't understand why.
here's the parser code:
Thanks in advance
I have a little question regarding xml data and arrays.
So i'm parsing an xml file and i'm trying to add the parsed data into an array which i can later use as the cell data for a table view.
i keep getting the last node from the xml and i don't understand why.
here's the parser code:
Code:
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict
{
if([elementName compare:@"ArticleTitle"])
{
currentAttribute = [NSMutableString string];
}
}
- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
{
if(![elementName compare:@"ArticleTitle"])
{
MeinaItemsArray = [[NSMutableArray alloc] initWithObjects:currentAttribute, nil];
NSLog(@"The is %@", MeinaItemsArray);
}
}
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
{
if(self.currentAttribute)
{
[self.currentAttribute appendString:string];
}
}
Thanks in advance