Search code examples
iphonensxmlparser

How to parse special characters using NSXMLPARSER


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.


Solution

  • - (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
    {
    
    
         catalogString = (NSMutableString *) [string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
    
    }
    

    this piece of code will remove ur special characters