Question

I'm coding an iOS app and I need to parse some values from an XML file. I'm parsing the XML using SMXMLDocument and everything works smooth but some tags are returning null value. I noted that those tags are CDATA and after some research I found some methods to workaround this thing. The problem is all those methods refer to NSXMLParser and I can't understand how to do this using SMXMLDocument. The code in my app is very similar (you could say identical) to the code at this page. Can you please help me? Thank you

Was it helpful?

Solution

Apparently SMXMLDocument does not conform to all of the NSXMLParser delegate functions when it parses your document. You are going to have to manually modify SMXMLDocument.m and add the function:

- (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock
 {  

}

Inside that function should look very similar to the foundcharacters function, you just need to take the NSData that you get and convert it into a string. Beware of encoding though, CData data is not always UTF8.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top