xml parsing iphone, objective C?

南笙酒味 提交于 2020-01-06 07:25:10

问题


i want to get data between xml tags? how to navigate? and get values..

im using wsdl2objc from google code:http://code.google.com/p/wsdl2objc/

output soapbody follows:

read instruction here: http://code.google.com/p/wsdl2objc/wiki/UsageInstructions

my header file: #import "MService.h"

how to get image source and text value????

please help me....


回答1:


 if([bodyPart isKindOfClass:[types_getFavoriteColorResponseType class]]) {
     types_getFavoriteColorResponseType *body = (types_getFavoriteColorResponseType*)bodyPart;
     // Now you can extract the color from the response
     q.text = body.color;
     continue;
}

Ок as far as I understand this is a part which extracts text data from your SOAP response.

BTW you need response to be processed via SAX or DOM? First example in given URL refers to DOM usage, whereas the second to SAX.

More than that I can not tell. Guess you have to read manual or find someone, who worked with this.




回答2:


Use NSXMLParser, NSXMLParserDelegate for xml parsing, you can get the callbacks with proper values:

parser:didStartElement:namespaceURI:qualifiedName:attributes: parser:foundCharacters: parser:didEndElement:namespaceURI:qualifiedName:

Ref: http://developer.apple.com/library/ios/#documentation/cocoa/reference/NSXMLParserDelegate_Protocol/Reference/Reference.html




回答3:


hey i got the result using sudzc.com

if ([result isKindOfClass:[MSalesPages class]]) {

    NSLog(@"Response");
    NSMutableArray* pageData = result.PageData;

    for(MSalesPage* page in pageData){
        NSLog(@"Inside for loop %@", page.Id);

        NSMutableArray* images = page.Images;
        NSMutableArray* textData = page.TextData;

        for(MSalesImg* img in images){
            NSLog(@"Image url %@",img.Src);
        }
        for(MSalesText* text in textData){
            NSLog(@"Product Name %@",text.Value);
        }
    }
}

carefully check with the above xml, u will get the answer :)



来源:https://stackoverflow.com/questions/4243070/xml-parsing-iphone-objective-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!