iphone - filter data from mediawiki api ios -
i used "action=query&prop=revisions&rvprop=content&titles=%@&format=json&redirects" api getting details anil_ambani. in response got following dictionary
<i> query = { normalized = ( { = "anil_ambani"; = "anil ambani"; } ); pages = { 1222313 = { ns = 0; pageid = 1222313; revisions = ( { "*" = "{{blp sources|date=june 2012}}\n{{infobox person\n| name = anil ambani \n| image =anilambani.jpg\n| image_size = \n| caption = ambani in 2009\n| birth_date = {{birth date , age|1959|6|4|df=y}}\n| birth_place = [[mumbai]], [[maharashtra]], [[india]]\n| nationality = indian\n| occupation = chairman of [[anil dhirubhai ambani group]] \n| networth = {{loss}} [[united states dollar|$]]5.2 billion (2012)<ref name=\"forbes.com\">[http://www.forbes.com/profile/anil-ambani/.] forbes.com. retrieved april 2013.</ref> \n| residence = mumbai, maharashtra, india\n| alma_mater = [[warwick business school]]<br />[[wharton school of university of pennsylvania|the wharton school]]\n| parents = [[dhirubhai ambani]]<br>kokilaben ambani\n| brother = [[mukesh ambani]]\n| spouse = [[tina ambani]]\n|
the value "" here nsstring. value "" is
<i>$3 = 0x0755bb50 {{blp sources|date=june 2012}} {{infobox person | name = anil ambani | image =anilambani.jpg | image_size = | caption = ambani in 2009 | birth_date = {{birth date , age|1959|6|4|df=y}} | birth_place = [[mumbai]], [[maharashtra]], [[india]] | nationality = indian</i>
now want filter string name, birth_date, etc. tried
<i>nsarray *arr=[htmlsrc componentsseparatedbystring:@"|"] (int i=2; i<mutarr.count; i++) { nsarray *dictkeyvaluearray=[str componentsseparatedbystring:@"="]; [maindict setobject:[dictkeyvaluearray objectatindex:1] forkey:[dictkeyvaluearray objectatindex:0]]; }
but crashing after birth_date. because there "|" after birth date , age. won't key value pair after birth_date.
please suggest me other way filter string.
the response getting in dictionary form. retrieving value of key "*" string. but, string contains html value. html show content in uiwebview in our app.
now, question value of particular key i.e name, birth_date, etc.:-
html string getting not definite because changed change input word (searched word), here, input word anil ambani, , response , html value.
so, don't think there definite way values of particular key.
updated:-
substring between 2 substring, can use this:-
-(nsstring*)usescannertogetsubstring:(nsstring*)stryourstring startstring:(nsstring*)startstring endstring:(nsstring*)endstring { nsstring * strtest = stryourstring; nsmutablearray *substrings = [nsmutablearray new]; nsscanner *scanner = [nsscanner scannerwithstring:strtest]; [scanner scanuptostring:startstring intostring:nil]; while(![scanner isatend]) { nsstring *substring = nil; [scanner scanstring:startstring intostring:nil]; if([scanner scanuptostring:endstring intostring:&substring]) { [substrings addobject:substring]; } [scanner scanuptostring:startstring intostring:nil]; } if ([substrings count]>0) { return [substrings objectatindex:0]; } return nil; }
Comments
Post a Comment