UTF8 from web content .xml file to NSString

2019-08-16 15:32发布

问题:

I can't find a way to convert some UTF8 encoding into NSString.

I get some data from a URL, it's a .xml file and here is their content:

<?xml version="1.0" encoding="UTF-8"?>
<person>
<name>Jim Fern&#225;ndez</name>
<phone>555-1234</phone>
</person>

How can I convert the & #225; into a á ?

some code that doesn't work:

 NSString* newStr = [[NSString alloc] initWithData:[NSData dataWithContentsOfURL:URL] encoding:NSUTF8StringEncoding];

edit:

I'm using the TBXML library

回答1:

Finally I'm using the NSString+XMLEntities from Michael Waterfall to decode .xml



标签: iphone xml utf-8