I need to get XML data from this particular address (https://www.cnb.cz/cs/financni_trhy/devizovy_trh/kurzy_devizoveho_trhu/denni_kurz.xml). But when I run the application, nothing happens. Also honestly I do not know how to get from the above xml id 1, id 2 and so on. I'll be happy for any of your advice. Thx
- (id)initWithArray: (NSMutableArray *)slovoArray {
self = [super init];
if (self) {
self.slovoArray = slovoArray;
}
return self;
}
- (void)parseXMLFile
{
NSURL *url = [[NSURL alloc] initWithString:@"https://www.cnb.cz/cs/financni_trhy/devizovy_trh/kurzy_devizoveho_trhu/denni_kurz.xml"];
self.parser = [[NSXMLParser alloc] initWithContentsOfURL:url];
self.parser.delegate = self;
[self.parser parse];
}
- (void)parser:(NSXMLParser *)parser
didStartElement:(NSString *)elementName
namespaceURI:(NSString *)namespaceURI
qualifiedName:(NSString *)qualifiedName
attributes:(NSDictionary *)attributeDict {
self.element = elementName;
if ([_element isEqualToString:@"radek"]) {
_item = [[NSMutableDictionary alloc] init];
self.kod = [[NSMutableString alloc] init];
self.kurz = [[NSMutableString alloc] init];
}
}
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
{
if ([self.element isEqualToString:@"kod"])
{
[self.kod appendString:string];
}
else if ([self.element isEqualToString:@"kurz"])
{
[self.kurz appendString:string];
}
}
- (void)parser:(NSXMLParser *)parser
didEndElement:(NSString *)elementName
namespaceURI:(NSString *)namespaceURI
qualifiedName:(NSString *)qName {
if ([elementName isEqualToString:@"radek"]) {
Slova *thisSlovo = [[Slova alloc] initWithName:self.kod
kurz:self.kurz];
[self.slovoArray addObject:thisSlovo];
}
self.element = nil;
}
@end