XML : How to parse a XML Data within a JSON Key?

I have a JSON coming from Server. I am parsing JSON. I am making objects from JSON and saving into ARRAY.

  XML PART within DATA object  @property (nonatomic, strong) NSString *subtitle;  @property (nonatomic, strong) NSString *type;  @property (nonatomic, strong) NSString *case_description;    @property (nonatomic, strong) NSString *case_id;  @property (nonatomic, strong) NSString *type_id;  @property (nonatomic, strong) NSString *sender_id;  @property (nonatomic, strong) NSString *data;    

In the last variable, data, it has complete XML inside it.

I need to extract data of variable "data" and put inside same object's other variable which are defined above.

  1.subtitle    2.type   3.case_description    

The XML is

  <?xml version="1.0" encoding="UTF-8"?>  <data>     <subtitle><![CDATA[aa]]></subtitle>     <type>Male</type>     <description><![CDATA[abc]]></description>  </data>    

When I do like this.

  -(void) findObjectAndAddInArray:(int) indexPoint{        if (_indexPoint == [_array_cases count]-1) {          dispatch_async(dispatch_get_main_queue(), ^{              [self.tableViewCase reloadData];          });            return;      }      current_case = [_array_cases objectAtIndex:indexPoint];      NSData *data = [current_case.data dataUsingEncoding:NSUTF8StringEncoding];      [self xmlParser:data];      _indexPoint++;    }    

Call this method within

  - (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName    

It crashes. It says, I can't call a XMLPARSER within XMLPARSER delegate method.

So, how can I modify my array or make new array which contain those objects which are inside "data" variable

Thanks.

No comments:

Post a Comment