Iphone XML data accentuation?

Cheawebe

New Member
I'm developing a project which fetch data from a php file(as XML).To be more clearly the app works like this:1-Send an HTTP Request to a PHP file,which select data from a mysql database and display it as XML,using the code bellow:\[code\] <?php header("Content-Type: text/html; charset=ISO-8859-1",true);echo(utf8_decode($xml->title)); $connect = mysql_connect("XX.XX.com", "XXX", "XXX") or die(mysql_error()); mysql_select_db("XXX") or die(mysql_error()); $id_get = $_GET['id'];$selectData = "http://stackoverflow.com/questions/10670904/SELECT * FROM teste_xml_accentuation WHERE id ='$id_get' ";$selectedData = http://stackoverflow.com/questions/10670904/mysql_query($selectData);?> <chat><?php while ($row = mysql_fetch_assoc($selectedData)) { $id = $row['id']; $added = $row['added']; $text = $row['text']; ?> <teste added="<?php echo"$added"; ?>" id="<?php echo"$id"; ?>"> <id> <?php echo"$id"; ?> </id> <added> <?php echo"$added"; ?> </added> <text> <?php echo"$text"; ?> </text> </teste> <?php } ?> </chat>\[/code\]This part is working fine,every type of chars are displayed well in my web browser.Now the second step is to get those data to my iOS application,for this i'm using the code bellow:\[code\]-(void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict { if ( [elementName isEqualToString:@"teste"] ) { msgAdded = [[attributeDict objectForKey:@"added"] retain]; msgId = [[attributeDict objectForKey:@"id"] intValue]; msgIDEN = [[NSMutableString alloc] init]; msgError = [[NSMutableString alloc] init]; inIDEN = NO; inError = NO; } if ( [elementName isEqualToString:@"id"] ) { inIDEN = YES; } if ( [elementName isEqualToString:@"text"] ) { inError = YES; }}-(void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string { if ( inIDEN ) { [msgIDEN appendString:string]; } if ( inError ) { [msgError appendString:string]; }}-(void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName { if ( [elementName isEqualToString:@"teste"] ) { [messages addObject:[NSDictionary dictionaryWithObjectsAndKeys:msgIDEN,@"id",msgAdded,@"added",msgError,@"text",msgErroNSS,@"text",nil]]; [[messages reverseObjectEnumerator] allObjects]; lastId = msgId; [msgAdded release]; [msgErroNSS release]; [msgError release]; NSLog(msgErroNSS); NSLog(msgError); NSLog(msgAdded); NSLog(@"Magalh?es"); } if ( [elementName isEqualToString:@"id"] ) { inIDEN = NO;} if ( [elementName isEqualToString:@"text"] ) { inError = NO;}}\[/code\]Again everything works well,but the problem is,if one of the string from the XML file contain any special chars(such as:
 
Back
Top