Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6385067
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:51:10+00:00 2026-05-25T02:51:10+00:00

I am trying to parse XML file which contains arabic words as follow: <NewsComponent>

  • 0

I am trying to parse XML file which contains arabic words as follow:

 <NewsComponent>
  <HeadLine>العلاجية</HeadLine>
</NewsComponent>

when I NSLog the string on the NSXMLParser delegate it prints empty string, and even when i parse the data to the UITableView it shows empty text.

I am encoding the data as UTF-8 before passing it to the parser.

How can I parse the XMl without losing the content of the tag HeadLine?

notes:

1. The same XML with English language is working correctly.

2. Showing the XML in Any browser shows the data correctly.

3. converting the NSData to NSString and NSLog-ing before parsing the NSString show the xml correctly too.


Edit How am I doing this?

NSString *sURLREST = @"http://www.example.com/getXml";

NSURL *url = [NSURL URLWithString:sURLREST];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];

NSURLResponse *response;
NSError *error = nil;

NSData *data = [NSURLConnection sendSynchronousRequest: request returningResponse: &response error: &error];
NSString* output = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];

NSData* dataOutput = [output dataUsingEncoding: NSUTF8StringEncoding];
NSXMLParser *parser = [[NSXMLParser alloc] dataOutput]; 


-(void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
{
    if([sCurrentItem isEqualToString:@"HeadLine"])
    {
        [mutuableArray addObject:string];
       // I am just adding the string value to a NSMutuableArray to bind it with the UITableView.
        NSLog(@"%@",string);
    }
}

- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict
{
    sCurrentItem = elementName;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T02:51:10+00:00Added an answer on May 25, 2026 at 2:51 am

    Your error lies in parser:foundCharacters:. You cannot expect that that method will be called only once per element. It may be called multiple times. You have to create an empty mutable string before the method is called the first time per element (in parser:didStartElement:) and then append the new characters to that string. The string is not complete until parser:didEndElement: is called.

    See Apple’s sample code. They do it correctly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am Trying To Use NSXMLParser to parse an xml file using cocoa which
I am trying to parse this xml file, which has some nested nodes. I
I'm trying parse the follow XML file: <root>Root <pai>Pai_1 <filho>Pai1,Filho1</filho> <filho>Pai1,Filho2</filho> </pai> <pai>Pai_2 <filho>Pai2,Filho1</filho>
I'm trying to parse an NZB file (which is XML) and sum the bytes
I am trying to parse the xml file which has collection of nested tags.I
Hi I am trying to Parse a local xml file (which has database table
I'm trying to parse an XML file, that file contains strings and integers. So
I'm trying to parse an xml file with PHP. I'm using this code and
I am trying to parse an XML file in java, after I have to
I am trying to parse an XML file into smaller XML files and place

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.