-1

Hi in my application I have to parse the xml file.That file have few special characters like apple&iphone ,here NSXMLPARSER cannot able to read this tag, It's reading only iphone not apple&iphone. Please show me the solution how to read these type of data which have special characters. Thanks in advance.

For example :

                    <Item>Apple&amp;i phone</Item>
        <serialno>a1212</serialno>
        <storeno>32</storeno>
        <address>bang</address>

xml file is like this here i have to read Item and i want to get the output as Apple&i phone. But now i am getting the output as i phone.

Naresh
  • 363
  • 1
  • 18

2 Answers2

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


     catalogString = (NSMutableString *) [string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];

}

this piece of code will remove ur special characters

Kasaname
  • 1,491
  • 11
  • 15
  • Hi kasaname i edited your answer please go through that and help me how to resolve that issue. – Naresh Jul 12 '13 at 06:25
  • are u putting the data in the respective model object and then to the respective array and then releasing the array – Kasaname Jul 12 '13 at 07:43
0

So you need to just capture then in NSMutableString. Then you can use CFStringTransform to convert them.

uchuugaka
  • 12,679
  • 6
  • 37
  • 55
  • Hi can you please elaborate. – Naresh Jul 12 '13 at 06:15
  • So use NSXMLParser to capture the things you're interested in. Build whatever data structure. For the string inside this element put it in an NSMutableString. You can pass that to the Core Foundation function CFStringTransform. It's a powerful function I've mentioned and others cover elsewhere. It wraps ICU library and let's you convert things like HTML or XML escape sequences into strings. – uchuugaka Jul 13 '13 at 07:32