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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T04:44:25+00:00 2026-05-30T04:44:25+00:00

I have ran into a peculiar problem with NSXMLParser. For some reason it cuts

  • 0

I have ran into a peculiar problem with NSXMLParser.

For some reason it cuts out all the characters in front of all the norwegian characters æ, ø and å.

However, the problem seems to be the same with all non a-z characters.(All foreign characters)

Examples:

Reality: Mål
Output: ål

Reality: Le chant des sirènes
Output: ènes

Heres an example from the log where I have printed out the string from:

- (void) parser:(NSXMLParser *)parser foundCharacters:(NSString *)string

Log:

2012-02-22 14:00:01.647 VotePlayClient[2776:207] found characters: Le chant des sir
2012-02-22 14:00:01.647 VotePlayClient[2776:207] found characters: ènes

You can clearly see that it jumps to a new line whenever it encounters a foreign letter.

I believe that I have to figure out how to append the string or something to that effect.

Here are the NSXMLParser files:

SearchXMLParser.h

#import <Foundation/Foundation.h>
#import "Search.h"

@interface SearchXMLParser : NSObject <NSXMLParserDelegate>
{
NSMutableString *currentNodeContent;
NSMutableArray *searchhits;
NSMutableArray *trackhits;

NSXMLParser *parser;
Search *currentSearch;  
}

@property (readonly, retain) NSMutableArray *searchhits;
@property (readonly, retain) NSMutableArray *trackhits;

-(id) loadXMLByURL:(NSString *)urlString;

@end

SearchXMLParser.m

#import "SearchXMLParser.h"
#import "Search.h"

@implementation SearchXMLParser

@synthesize searchhits, trackhits;

-(id) loadXMLByURL:(NSString *)urlString
{
    searchhits          = [[NSMutableArray alloc] init];
trackhits           = [[NSMutableArray alloc] init];
NSURL *url      = [NSURL URLWithString:urlString];
NSData  *data   = [[NSData alloc] initWithContentsOfURL:url];
parser          = [[NSXMLParser alloc] initWithData:data];
parser.delegate = self;
[parser parse];
return self;    
}

- (void) parser:(NSXMLParser *)parser didStartElement:(NSString *)elementname namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict
{
if ([elementname isEqualToString:@"track"]) 
{
    currentSearch = [Search alloc];
}

if ([elementname isEqualToString:@"track"]) 
{
    currentSearch.trackurl = [attributeDict objectForKey:@"href"];
}
}

- (void) parser:(NSXMLParser *)parser didEndElement:(NSString *)elementname namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
{   
if ([elementname isEqualToString:@"name"]) 
{
    [trackhits addObject:currentNodeContent];

}

if ([elementname isEqualToString:@"track"]) 
{
    currentSearch.track = [trackhits objectAtIndex:0];
    currentSearch.artist = [trackhits objectAtIndex:1];
    currentSearch.album = [trackhits objectAtIndex:2];
    [trackhits removeAllObjects];

    [searchhits addObject:currentSearch];
    [currentSearch release];
    currentSearch = nil;
    [currentNodeContent release];
    currentNodeContent = nil;
}
}

- (void) parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
{
NSLog(@"found characters: %@", string);
currentNodeContent = (NSMutableString *) [string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
}

- (void) dealloc
{
[parser release];
[super dealloc];
}

@end

I have already checked SO for answers and found a couple of similar posts, but nothing that gave a clear solution to this problem.

Can anyone shed some light on this problem? 🙂 Any help is much 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-05-30T04:44:26+00:00Added an answer on May 30, 2026 at 4:44 am

    your parser:foundCharacters: method does not work as it should.

    This is from the NSXMLParserDelegate Protocol Reference

    The parser object may send the delegate several parser:foundCharacters: messages to report the characters of an element. Because string may be only part of the total character content for the current element, you should append it to the current accumulation of characters until the element changes.

    you could try something like this (ARC):

    - (void) parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
    {
        NSLog(@"found characters: %@", string);
        if (!currentNodeContent) {
            currentNodeContent = [[NSMutableString alloc] init];
        }
        [currentNodeContent appendString:string];
    }
    
    - (void) parser:(NSXMLParser *)parser didEndElement:(NSString *)elementname namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
    {   
        // your code here
    
        // when you are done with the string:
        currentNodeContent = nil;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Maybe some of you could have ran into the same problem i did. Imagine
Currently developing a PHP framework and have ran into my first problem. I need
Never ran into this problem with jQuery before. I have the following: $(document).ready(function() {
Today I ran into the following problem with NUnit. I have a class, that
I have ran into yet another problem I do not understand. The following does
Alright, I have ran into a problem when using DownloadDataAsync and having it return
I recently started programming my first Cocoa app. I have ran into a problem
I ran into a peculiar problem today when I wanted to migrate the history
I have ran into a bit of a problem with my understanding of the
im creating a like system but i have ran into a problem, with when

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.