-1

I need help to parse data response. When I send parameter to Web Service then Web Service will give data in response I'm used wsdl2objc

for( ; cur != NULL ; cur = cur->next) {
            if(cur->type == XML_ELEMENT_NODE) {

                if(xmlStrEqual(cur->name, (const xmlChar *) "Body")) {
                    NSMutableArray *responseBodyParts = [NSMutableArray array];

                    xmlNodePtr bodyNode;
                    for(bodyNode=cur->children ; bodyNode != NULL ; bodyNode = bodyNode->next) {
                        if(cur->type == XML_ELEMENT_NODE) {
                            if(xmlStrEqual(bodyNode->name, (const xmlChar *) "selectDataReturn")) {
                                NSString  *bodyObject = [NSString  deserializeNode:bodyNode];

                                if (bodyObject != nil) [responseBodyParts addObject:bodyObject];


                            }

                            if (xmlStrEqual(bodyNode->ns->prefix, cur->ns->prefix) && 
                                xmlStrEqual(bodyNode->name, (const xmlChar *) "Fault")) {
                                SOAPFault *bodyObject = [SOAPFault deserializeNode:bodyNode];

                                if (bodyObject != nil) [responseBodyParts addObject:bodyObject];

                            }
                        }
                    }

                    response.bodyParts = responseBodyParts;

                    //bodyParts is my data.

                }
            }
        }

But my bodyParts response to me:

<?xml version='1.0' encoding='UTF-8'?><EISDataRS><EISDataRecord><RECSEQ>1</RECSEQ><INPUT_DATE>201201</INPUT_DATE><PREFIX_BU>AAA</PREFIX_BU><INDEX_LEVEL>10000</INDEX_LEVEL><CF>83.94</CF></EISDataRecord><EISDataRecord><RECSEQ>2</RECSEQ><INPUT_DATE>201201</INPUT_DATE><PREFIX_BU>AAA</PREFIX_BU><INDEX_LEVEL>20100</INDEX_LEVEL><CF>73.94</CF></EISDataRecord><EISDataRecord><RECSEQ>1</RECSEQ><INPUT_DATE>201201</INPUT_DATE><PREFIX_BU>AAA</PREFIX_BU><INDEX_LEVEL>22100</INDEX_LEVEL><CF>57.44</CF></EISDataRecord></EISDataRS>

How I can parse data in wsdl2objc or how should I parse on resp.bodyParts in view controller I just need text data only Please Advice. Thanks.

Sabby
  • 2,586
  • 2
  • 27
  • 41
  • Have you done any research? There are a vast number of existing resources about how to parse an XML file in iOS. Please do some search starting with all of the related questions to yours. – rmaddy Aug 21 '13 at 02:02
  • possible duplicate of [Parsing xml in NSXMLParser](http://stackoverflow.com/questions/8813968/parsing-xml-in-nsxmlparser) – rmaddy Aug 21 '13 at 02:02
  • I'm use wsdl2objc to parse data but i don't know to edit wsdl2objc – Masataga.Takashi Aug 21 '13 at 02:06
  • can i use nsxmlparser in wsdl2objc if(xmlStrEqual(bodyNode->name, (const xmlChar *) "selectDataReturn")) { NSString *bodyObject = [NSString deserializeNode:bodyNode]; if (bodyObject != nil) [responseBodyParts addObject:bodyObject]; } – Masataga.Takashi Aug 21 '13 at 02:14

2 Answers2

0

If you want to parse XML data, look into XMLDictionary.

It is an easy framework that easily parses your data into a neat and ordered hierarchy of NSDictionaries and NSArrays.

https://github.com/nicklockwood/XMLDictionary

srz2
  • 162
  • 1
  • 10
0

I had the same issue and I fixed it by parsing the correct body name.

In your code, try replacing selectDataReturn with EISDataRS. Because from your response I can see EISDataRS is your child.

Salim
  • 85
  • 11