开发者

TouchXML (Sudzc) and using this data properly

I am using Sudzc (it uses TouchXML) for parsing my web services WSDL, now I am using multiple web services with almost the same WSDL definitions. I edited my code to use this, this is what happens:

CXMLNode* element = [[Soap getNode: [doc rootElement] withName: @"Body"] childAtIndex:0];
output = [Soap deserialize:element];

And the soap deserialize is as following:

// Deserialize an object as a generic object
+ (id) deserialize: (CXMLNode*) element{
      return [element stringValue];
}

I get data back ilke this when I log it:

{
    RetrieveSetResult =     {
        Entities =         {
            RequestData =             {
                AccountCode =                 {
                    IsDirty = false;
                    IsNothing = true;
                    NoRights = false;
                    Value = "<null>";
                };
                AccountContactEmail =                 {
                    IsDirty = false;
                    IsNothing = true;
                    NoRights = false;
               开发者_StackOverflow社区     Value = "<null>";
                };
            };
        };
        SessionID = 40;
    };
}

How can I use this data in a user friendly way, so i want to be able to say which field I want to select and read.


try access them like a dictionary

NSDictionary *dic = [myXMLparsedObject valueForKey:@"RetrieveSetResult"];
int sesID = [[dic valueForKey:@"SessionID"] intValue];
NSDictionary *entis = [dic valueForKey:@"Entities"];
// … and so on

looping through all elements:

// for iOS prior 4.0
NSArray *dicKeys = [xmlDic allKeys];
for (NSString *key in dicKeys) {
    id obj = [xmlDic valueForKey:key];
}

// way simpler in > 4.0
[xmlDic enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {

}];

in both cases you can access each key and obj value ;)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜