'Parse XML Data response

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.



Solution 1:[1]

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

Solution 2:[2]

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.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 srz2
Solution 2