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 7763303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T14:37:30+00:00 2026-06-01T14:37:30+00:00

I am Getting a weird problem. I am making an App which should run

  • 0

I am Getting a weird problem. I am making an App which should run on Both iOS 4 & 5.When i parse my XML in iOS 5 It is doing great and i am getting my output, but when i am Trying to do the same in iOS 4 ,i am getting this error “NSXMLParserErrorDomain error 31“. in the

- (void)parser:(NSXMLParser *)parser parseErrorOccurred:(NSError *)parseError;

my XML is like this.. i need to parse the title tag within Item tag…

<item> <title> <![CDATA[ Cynical approach to tar my reputation: Army    Chief on leaked letter ]]> </title> <link> <![CDATA[ ]]> </link>    <guid isPermaLink="false"> <![CDATA[ ]]> </guid> </item> <item>    <title> <![CDATA[ Major fire in scrap godown in suburban Mumbai ]]>    </title> <link> <![CDATA[ ]]> </link> <guid isPermaLink="false">    <![CDATA[ ]]> </guid> </item>

My parsing code id this :-

-(void)parseBN{

    NSString *URL=@"My XML's URL";

    // convert the path to a proper NSURL
    NSURL *xmlURL = [NSURL URLWithString:URL];
    CTNetworking *request= [CTNetworking requestWithUrl:xmlURL];
    [request setDelegate:self];
    [request setDidFinishSelector:@selector(startParse:)];
    [request startRequest];

}

-(void)startParse:(CTNetworking*)response{

    if (response.responseStatusCode == 200 && rssParser == nil) {
        [stories removeAllObjects];

        NSString *myStr = [[NSString alloc] initWithData:[response responseData] encoding:NSWindowsCP1251StringEncoding];
        myStr = [myStr stringByReplacingOccurrencesOfString:@"encoding=\"windows-1251\"" withString:@""];


        NSData* aData = [myStr dataUsingEncoding:NSASCIIStringEncoding];


     //   NSXMLParser *parser = [[NSXMLParser alloc] initWithData:aData];

        rssParser = [[NSXMLParser alloc] initWithData:aData];
     //   rssParser = [[NSXMLParser alloc] initWithData:[response responseData]];
        // Set self as the delegate of the parser so that it will receive the parser delegate methods callbacks.
        [rssParser setDelegate:self];

        // Depending on the XML document you're parsing
        [rssParser setShouldProcessNamespaces:NO];
        [rssParser setShouldReportNamespacePrefixes:NO];
        [rssParser setShouldResolveExternalEntities:NO];

        [rssParser parse];
    }


}

- (void)parserDidStartDocument:(NSXMLParser *)parser{   

}

- (void)parser:(NSXMLParser *)parser parseErrorOccurred:(NSError *)parseError {
    NSString * errorString = [NSString stringWithFormat:@"Unable to download story feed from web site (Error code %i )", [parseError code]];
    NSLog(@"error parsing XML: %@", errorString);

    UIAlertView * errorAlert = [[UIAlertView alloc] initWithTitle:@"Error loading content" message:errorString delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [errorAlert show];
}

- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict{    

It is not coming here.. so didn't paste the Inside code

}

I searched in google for this error and everybody saying this error comes because of Unknown Encoding.. so i tried with “NSWindowsCP1251StringEncoding” also instead of default Encoding.
Any Help will be Appreciated.

  • 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-06-01T14:37:32+00:00Added an answer on June 1, 2026 at 2:37 pm

    Finally i got it working…

    NSString *myStr = [[[NSString alloc] initWithData:[response responseData] encoding:NSWindowsCP1251StringEncoding] autorelease];
        myStr = [myStr stringByReplacingOccurrencesOfString:@"encoding=\"windows-1251\"" withString:@""];
        myStr = [myStr stringByReplacingOccurrencesOfString:@"US-ASCII" withString:@"UTF-8"];
        NSData* aData = [myStr dataUsingEncoding:NSASCIIStringEncoding];
    
        rssParser = [[NSXMLParser alloc] initWithData:aData];
        [rssParser setDelegate:self];
        [rssParser setShouldProcessNamespaces:NO];
        [rssParser setShouldReportNamespacePrefixes:NO];
        [rssParser setShouldResolveExternalEntities:NO];
    
        [rssParser parse];
    

    Changed the Encoding type through NSString 🙂

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

Sidebar

Related Questions

I have a pretty weird problem in my iPhone app which is, I think,
I'm getting a weird problem in GlassFish 2.1 - I'm a beginner with this
Super weird problem here. I'm having trouble getting jQuery to bind any selectors except
I'm having this weird problem where other instances of my jQuery plugin are getting
I am getting weird problem, the crash happens at random times, for example i
Getting a weird problem when uploading a spreadsheet via C#. Here's an example of
I'm just getting started developing for Android and I'm running into a weird problem.
I've run into a weird problem yesterday. I am using selenium-rc along with C#
I'm getting a weird problem with TinyMCE. When I click the cursor to the
I just upgraded to rails 3.1 and is getting a weird routing problem with

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.