title: NSXMLParserErrorDomain error 31
body: <p>I getting this  error when retrieve xml request from <a href="http://www.cbr.ru/scripts/XML_daily.asp" rel="nofollow">http://www.cbr.ru/scripts/XML_daily.asp</a></p>
  
  <p>XML code like this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="windows-1251" ?&gt;
  &lt;ValCurs Date="01.03.2011" name="Foreign Currency Market"&gt;
  &lt;Valute ID="R01010"&gt;
      &lt;NumCode&gt;036&lt;/NumCode&gt;
      &lt;CharCode&gt;AUD&lt;/CharCode&gt;
      &lt;Nominal&gt;1&lt;/Nominal&gt;
      &lt;Name&gt;Австралийский доллар&lt;/Name&gt;
      &lt;Value&gt;29,3508&lt;/Value&gt;
  &lt;/Valute&gt;
  &lt;Valute ID="R01020A"&gt;
      &lt;NumCode&gt;944&lt;/NumCode&gt;
      &lt;CharCode&gt;AZN&lt;/CharCode&gt;
      &lt;Nominal&gt;1&lt;/Nominal&gt;
      &lt;Name&gt;Азербайджанский манат&lt;/Name&gt;
      &lt;Value&gt;36,3374&lt;/Value&gt;
  &lt;/Valute&gt;
  </code></pre>
  
  <p>My code is:</p>
  
  <pre><code>-(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];
  }
  </code></pre>
  
  <p>........</p>
  
  <pre><code>- (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];
  } 
  </code></pre>
  
  <p>From NSXMLParser reference -NSXMLParserUnknownEncodingError = 31. 
  May be i need use encoding to NSWindowsCP1251StringEncoding for solve problem ?</p>