views:

106

answers:

3

hi!How should i parse data which contains CDATA in the Attribute?

A: 

If you could, I'ld really suggest converting this to JSON-data. The JSON-framework is lots easier to use. Else, I'ld suggest to use the TouchXML-classes (but they're a bit complicated in my opinion because they return elements with attributes instead of plain NSDictionaries and NSArrays).

TouchXML: http://code.google.com/p/touchcode/wiki/TouchXML

JSON-framework: http://code.google.com/p/json-framework/

Tim van Elsloo
how can i convert it in to JSON-data please if you have any idea let me know.
Ankit Vyas
Well, I don't know where your data is from, but if it's not your source you could check whether they support JSON-ouput (for example: Twitter does). If it's your own source you could read some documentation about JSON and translate your code into JSON-compatible code. But I'm not totally sure you know about JSON and stuff do you?
Tim van Elsloo
i have checked that my data is not in JSON Format.It means it is not parsed using JSON.I have got response like above so do you have any idea how to parse above data.
Ankit Vyas
Yes, use the first link I gave you (TouchXML) :). But I was talking about your datasource (where you got this response from). Maybe they could also output their responses in JSON-format which would make it lots easier :).
Tim van Elsloo
A: 

I suggest to read the following Apple documentation, it should explain that.

http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/NSXML_Concepts/NSXML.html

DarkDust
`NSXML` is not available on iOS.
falconcreek
+1  A: 

Read Event-Driven XML Programming Guide One way to do it is to use NSXMLParser to parse the data. Implement NSXMLParserDelegate's parser:foundCDATA: to capture the data in the CDATA element.

There are lots of examples of how to use NSXMLParser.

falconcreek