Monday, 2 February 2015

Wrong value for url from xml



I parse a xml with this structure :



"title": "VIDEO. Philippines : six millions de fidèles à Manille pour la messe du pape François",
"description": "Le pape François a célébré une messe géante, ce dimanche, au Rizal Park de Manille (Philippines), en présence de six millions de fidèles rassemblés sous une pluie battante. La tempête tropicale...",
"pubDate": "Sun, 18 Jan 2015 09:05:00 +0100",
"link": "http://ift.tt/1zpj2np",
"enclosure": {
"_url": "http://ift.tt/1LCQuKV",
"_length": "76019",
"_type": "image/jpeg"
}
},


Here is my code :



- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string{

if ([currentElement isEqualToString:@"title"]) {
[currentTitle appendString:string];

else if ([currentElement isEqualToString:@"enclosure"]) {

[currentPhoto appendString:string];
}



- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName{

if ([elementName isEqualToString:@"item"]) {

[item setObject:currentTitle forKey:@"title"];
[item setObject:currentPhoto forKey:@"url"];
[stories addObject:[item copy]];


}


and the value of url which i obtained is :


url = "\n \n ";


If in xml i dont have an image , i obtain url="" ;


No comments:

Post a Comment