iphoneiosxml-parsingtbxml

How to get the Arabic text using TBXML parser?


I have Arabic text in XML as shown below.

Code:

NSString *theXML = [[NSString alloc]
                    initWithBytes: [webData mutableBytes] //webData has received data
                    length:[webData length]
                    encoding:NSUTF8StringEncoding];         
NSLog(@"result %@",theXML);

NSLog Result:

 <media:title type='plain'>أحبج يا كويت</media:title>

After parsing using TBXML parser

Code:

 if ([[TBXML attributeName:attribute] isEqualToString:@"type"]
      &&[[TBXML elementName:element] isEqualToString:@"media:title"])
            {
                NSLog(@"%s",element->text);
            }

I am getting this

NSLog Result:

  برنامج تويتر رمضاني ح4 [ خلك حضاري ]

I need it to be in Arabic not the text as shown above.

Any suggestion will be appreciated


Solution

  • I managed it myself after one day efforts, answer lies in

    [TBXML textForElement:element] // Method
    

    instead of

    element->text. 
    

    Hope it will helps for other users in coming future.