Web Url contains Spanish Characters which my NSXMLParser is not parsing
Posted
by
mAc
on Stack Overflow
See other posts from Stack Overflow
or by mAc
Published on 2011-11-14T10:16:55Z
Indexed on
2011/11/15
9:51 UTC
Read the original article
Hit count: 233
I am Parsing Web urls from server and storing them in Strings and then displaying it on Webview. But now when i am parsing Spanish words like
http://litofinter.es.milfoil.arvixe.com/litofinter/PDF/Presentación_LITOFINTER_(ES).pdf
it is accepting it
PDF File Name ++++++ http://litofinter.es.milfoil.arvixe.com/litofinter/PDF/Presentaci
PDF File Name ++++++ ón_LITOFINTER_(ES).pdf
i.e two different strings... i know i have to make small change that is append the string but i am not able to do it now, can anyone help me out. Here is my code :-
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict
{
currentElement = elementName;
if([currentElement isEqualToString:@"category"]) {
NSLog(@"Current element in Category:- %@",currentElement);
obj = [[Litofinter alloc]init];
obj.productsArray = [[NSMutableArray alloc]init];
}
if([currentElement isEqualToString:@"Product"]) {
obj.oneObj = [[Products alloc]init];
}
}
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
{
if([currentElement isEqualToString:@"Logo"]) {
obj.cLogo=[NSString stringWithFormat:@"%@",string];
NSLog(@"Logo to be saved in Array :- %@",obj.cLogo);
}
if([currentElement isEqualToString:@"Name"]) {
obj.cName=[NSString stringWithFormat:@"%@",string];
NSLog(@"Name to be saved in Array :- %@",string);
}
if([currentElement isEqualToString:@"cid"]) {
obj.cId=(int)[NSString stringWithFormat:@"%@",string];
NSLog(@"CID to be saved in Array :- %@",string);
}
if([currentElement isEqualToString:@"pid"]) {
//obj.oneObj.id = (int)[NSString stringWithFormat:@"%@",oneBook.id];
obj.oneObj.id = (int)[oneBook.id intValue];
}
if([currentElement isEqualToString:@"Title"]) {
obj.oneObj.title = [NSString stringWithFormat:@"%@",string];
}
if([currentElement isEqualToString:@"Thumbnail"]) {
obj.oneObj.thumbnail= [NSString stringWithFormat:@"%@",string];
}
// problem occuriing while parsing Spanish characters...
if([currentElement isEqualToString:@"pdf"]) {
obj.oneObj.pdf = [NSString stringWithFormat:@"%@",string];
NSLog(@"PDF File Name ++++++ %@",string);
}
}
- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
{
if([elementName isEqualToString:@"category"]) {
NSLog(@"Current element in End Element Category:- %@",currentElement);
[TableMutableArray addObject:obj];
}
if([elementName isEqualToString:@"Product"]) {
[obj.productsArray addObject:obj.oneObj];
}
currentElement = @"";
}
I will be thankful to you.
© Stack Overflow or respective owner