I have an xml file with some rows like this:
<Country ID="" Name="Italy" />
<City ID="" Name="Rome" />
<Place ID="" Name="Colosseum">
but when I parse it the element Country or City or Place are empty (line break)
My code is:
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string{
if ([currentElement isEqual:@"Country"]) {
NSLog(@"Country %@", string);
}
}
Any help is appreciated.
Thanks,
Max
The values you see in your xml are the element attributes, not element data. So it wont show up in ‘foundCharacters’ method.
You will have to fetch the attribute values from the attributes dictionary in ‘didStartElement’ method: