Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

roeik

macrumors member
Original poster
Dec 25, 2008
80
0
I am using an XML parser to parse an RSS feed (parsing into strings).

For some reason I am getting the string in a different format. I think it's an HTML format since but I am not sure.

For example this text: Here is a “quote”

Will be displayed: Here is a &#8220quote&#8221

Any ideas how to fix this?

Thanks. Roei.
 

Guiyon

macrumors 6502a
Mar 19, 2008
771
4
Cambridge, MA
It's doing exactly what it should be. The quote characters you are using are not the ASCII quote characters, they are "smart quote" HTML character entities (ldquo and rdquo). You will either need to substitute the sequence with the proper left and right Unicode entities when you encounter them if you want the proper left and right quotes or just substitute in the standard quote character (ASCII/UTF8 char 0x22)
 

roeik

macrumors member
Original poster
Dec 25, 2008
80
0
How do I substitute in the e standard quote character (ASCII/UTF8 char 0x22)?

Shall I do it with the parser or with the NSString object? Is there a method that does it?

Thanks.
 

Guiyon

macrumors 6502a
Mar 19, 2008
771
4
Cambridge, MA
The easiest method would probably be to use stringByReplacingOccurrencesOfString:withString: on the NSString instance, or replaceOccurrencesOfString:withString:options:range: if it's an NSMutableString instance, after doing the parsing. Check the documentation if you need more information on the methods.
 

Darkroom

Guest
Dec 15, 2006
2,445
0
Montréal, Canada
just a side note here: XMLParser is (usually) much slower than LibXML2. if you are parsing hundreds of elements you may want to consider LibXML. check out Apple's "XMLPerformance" sample code to see the difference between the two parsers.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.