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 ;)
精彩评论