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

  • Home
  • SEARCH
  • 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 4029066
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:17:55+00:00 2026-05-20T11:17:55+00:00

I getting this error when retrieve xml request from http://www.cbr.ru/scripts/XML_daily.asp XML code like this:

  • 0

I getting this error when retrieve xml request from http://www.cbr.ru/scripts/XML_daily.asp

XML code like this:

<?xml version="1.0" encoding="windows-1251" ?>
<ValCurs Date="01.03.2011" name="Foreign Currency Market">
<Valute ID="R01010">
    <NumCode>036</NumCode>
    <CharCode>AUD</CharCode>
    <Nominal>1</Nominal>
    <Name>Австралийский доллар</Name>
    <Value>29,3508</Value>
</Valute>
<Valute ID="R01020A">
    <NumCode>944</NumCode>
    <CharCode>AZN</CharCode>
    <Nominal>1</Nominal>
    <Name>Азербайджанский манат</Name>
    <Value>36,3374</Value>
</Valute>

My code is:

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

 [articles removeAllObjects];
} 

-(void)parser:(NSXMLParser *)parser
didStartElement:(NSString *)elementName
namespaceURI:(NSString *)namespaceURI
qualifiedName:(NSString *)qualifiedName
attributes:(NSDictionary *)attributeDict
{
    currentElement = elementName;
    if ([elementName isEqualToString:@"ValCurs"]) {
        itemActive = YES;
        currentValute = [[NSMutableString alloc]init];
        currentNumCode = [[NSMutableString alloc]init];
        currentCharCode = [[NSMutableString alloc]init];
        nominal = [[NSMutableString alloc]init];
        currentName = [[NSMutableString alloc]init];
        currentValue = [[NSMutableString alloc]init];
    }
    }

-(void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
{
    if (itemActive) {
        NSString *fixedString = [string     stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
        if ([currentElement isEqualToString:@"Valute"]) 
            [currentValute appendString:fixedString];
        if ([currentElement isEqualToString:@"NumCode"]) 
            [currentNumCode appendString:fixedString];
        if ([currentElement isEqualToString:@"CharCode"]) 
            [currentCharCode appendString:fixedString];
        if ([currentElement isEqualToString:@"Nominal"]) 
            [nominal appendString:fixedString];
        if ([currentElement isEqualToString:@"Name"])
            [currentName appendString:fixedString];
        if ([currentElement isEqualToString:@"Value"])
            [currentValue appendString:fixedString];


}       
}

-(void)parser:(NSXMLParser *)parser
didEndElement:(NSString *)elementName
namespaceURI:(NSString *)namespaceURI
qualifiedName:(NSString *)qName
{
    if ([elementName isEqualToString:@"ValCurs"]) {
        NSDictionary *record = [NSDictionary dictionaryWithObjectsAndKeys:
                                currentValute,@"Valute",
                                currentNumCode,@"NumCode",
                                currentCharCode,@"CharCode",
                                nominal,@"nominal",
                                currentName,@"Name",
                                currentValue,@"Value",
                                nil];
        [articles addObject:record];
        [currentNumCode release];
        [currentCharCode release];
        [currentValute release];
        [nominal release];
        [currentName release];
        [currentValue release];
        itemActive = NO;
    }
    }

-(void)parserDidEndDocument:(NSXMLParser *)parser
{
    NSLog(@"%@",articles);
//text.text = (@"%@",currentCharCode);
}

-(void)retrieveXML:(id)sender
{
    [parser parse];
}

……..

- (void)viewDidLoad {
    [super viewDidLoad];
    articles = [[NSMutableArray alloc]init];
    NSString *myURL = [NSString     stringWithFormat:@"http://www.cbr.ru/scripts/XML_daily.asp"];

    NSURL *url = [NSURL URLWithString:myURL];
    //NSString *urla = [NSString stringWithContentsOfURL:url     encoding:NSUTF8StringEncoding error:nil];
    parser = [[NSXMLParser alloc]initWithContentsOfURL:url];
    parser.delegate = self;
    [self createUI];
} 

From NSXMLParser reference -NSXMLParserUnknownEncodingError = 31.
May be i need use encoding to NSWindowsCP1251StringEncoding for solve problem ?

  • 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-20T11:17:56+00:00Added an answer on May 20, 2026 at 11:17 am

    NSXMLParserUnknownEncodingError = 31 occurs when document encoding is unknown.

    Try this:

    NSString *myStr = [[NSString alloc] initWithData:myData encoding:NSWindowsCP1251StringEncoding];
    myStr = [myStr stringByReplacingOccurrencesOfString:@"encoding=\"windows-1251\"" withString:@""];
    
    
    NSData* aData = [myStr dataUsingEncoding:NSUTF8StringEncoding];
    
    
    NSXMLParser *parser = [[NSXMLParser alloc] initWithData:aData];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am getting this error when I try to extract information from an XML
Am getting this error for my code: Undefined symbols for architecture x86_64: _spendDollars, referenced
I am getting this error from eway token payment API, soap:ReceiverServer was unable to
I am getting this error when I retrieve a row with a null DataTime
I am getting this error while trying to retrieve a user profile: An error
I am getting this error when I try to retrieve some data. Here is
I keep getting this error and the error point to this code: bitmap =
Getting this error: 2009-09-03 12:44:02.307 xcodebuild[307:10b] warning: compiler 'com.apple.compilers.llvm.clang.1_0.analyzer' is based on missing compiler
Getting this error with jquery & jquery.form. Site has been live for awhile..upgraded to
Getting this error when try to add an item to my repositories/context: Collection has

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.