I m working on a chat application and i m getting a HTML response inside JSON response from server as chat History. Below is the response.
{ "status": "valid","chats": [{ "ces": "d5c15cf47d8e8684cfbebbc606f7d901", "fav":"0", "text": "<div class='ca'><i>sometext</i></div><><div class='ca'><b>prasad</b> has joined the chat.</div><><cid_1358766005><div class='co'><span class='notranslate'><b>prasad<timestamp_1358766041_co>:</b></span> hi</div></cid_1358766005><><div class='cl'><disconnected><d6>The party has left or disconnected. Chat session has ended.</div><>" } ] }
I want to separate them and Show in a table view.
I just tried to strip the HTML tag with the following category :
-(NSString *) stringByStrippingHTML {
NSRange r;
NSString *s = [self copy] ;
while ((r = [s rangeOfString:@"<[^>]+>" options:NSRegularExpressionSearch]).location != NSNotFound)
s = [s stringByReplacingCharactersInRange:r withString:@""];
return s;
}
But i m not getting all the data. I m never getting the timestamp. Please any one guide me How to get all the data.Thanks for your time.
You can use NSXMLParser. It’s Apple’s class for parsing XML documents.
Or else there are lot of open source libraries like TinyXML,Seismic XML etc for parsing XML documents.
Hope it Helps !!!