-2

In XML File, i have this symbol in middle of element like below showing code.

<title>CHAIRMAN BOB LIEBER INTERVIEWED BY CITY &amp; STATE</title>

once i read this content, i will get STATE only. So how to solve this issue to get like this, CHAIRMAN BOB LIEBER INTERVIEWED BY CITY & STATE

Wain
  • 118,658
  • 15
  • 128
  • 151
Muthu Sabarinathan
  • 1,198
  • 2
  • 21
  • 49

2 Answers2

0

I had same issue in my application

NSString* contents = [NSString stringWithContentsOfURL:[NSURL URLWithString:LINK_EVENTS_XML] encoding:NSUTF8StringEncoding error:nil];

// You can pre-process(replace certain characters, ...) content of xml in here.

NSData* xml = [contents dataUsingEncoding:NSUTF8StringEncoding];

NSXMLParser *nsXmlParser = [[NSXMLParser alloc] initWithData:data];

// create and init our delegate
XMLParser *parser = [[XMLParser alloc] initXMLParser];

// set delegate
[nsXmlParser setDelegate:parser];

// parsing...
BOOL success = [nsXmlParser parse]; if (success)
{
    NSLog(@"No errors - event count : %i", [parser.events count]);
    // get array of users here
    //  NSMutableArray *users = [parser users];

    self.eventsArray= parser.events;
    [self.tblEvents reloadData];
}
else
{
    NSLog(@"Error parsing document!");
}

I figured it had something to do with encoding.

Zeeshan
  • 4,194
  • 28
  • 32
0

I Found answer by myself just append the strings.

- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
{
    if (!currentStringValue)
    {
        currentStringValue = [[NSMutableString alloc] init];
    }
    else
    {
    [currentStringValue appendString: [string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]];

    }

}
Muthu Sabarinathan
  • 1,198
  • 2
  • 21
  • 49