reading values from ISO-8859-1 encoded xml

42 views
Skip to first unread message

Jorge

unread,
Nov 12, 2009, 1:04:27 PM11/12/09
to KissXML
Im reading rss2.0 content that is encoded using ISO-8859-1 like this:

DDXMLDocument *document = [[DDXMLDocument alloc]
initWithXMLString:content options:0 error:&error];
DDXMLElement* root = [document rootElement];

If if NSLog content variable it's displayed ok. But if I do this:

for (DDXMLElement *item in items){
title = [[[item elementsForName:@"title"] objectAtIndex:0]
stringValue];
NSLog(@"%@",tempNew.title);
}

I get "López" instead of "López"

Am I doing something wrong? Thanks!

Nathan de Vries

unread,
Nov 12, 2009, 7:39:50 PM11/12/09
to kis...@googlegroups.com
On 13/11/2009, at 5:04 AM, Jorge wrote:
> [[DDXMLDocument alloc] initWithXMLString:content options:0
> error:&error];

The problem is likely to be with the NSString you're initialising the
document with. Make sure you use NSISOLatin1StringEncoding when
creating the string, using something like NSString's
initWithData:encoding: API.


Cheers,

Nathan de Vries

Jorge

unread,
Nov 13, 2009, 5:03:09 AM11/13/09
to KissXML
I'm initializing the string in the right way (I think):

content = [[NSString alloc] initWithData:contentData
encoding:NSISOLatin1StringEncoding];

if I NSLog content it displays ok with accents and everything. It's
the method stringValue what is returning a weird value.
Reply all
Reply to author
Forward
0 new messages