PDA

View Full Version : Parsing XML RPC response




soc
Feb 12, 2009, 12:58 PM
Need help... I'm making getting a XML RPC response but seems the result is already formatted
in a non xml way.

If I look at the kWSDebugIncomingBody it is formatted as XML but the actual result is
formatted differently.

Is it possible to use the result (non xml) as a dictionary to parse the result instead of using the debug output
to parse as xml in an NSXMLParser ?

If so what would be the best way ?

result = (NSDictionary *) (WSMethodInvocationInvoke (rpcCall));

if (WSMethodResultIsFault ((CFDictionaryRef) result)) /*error?*/ {
NSLog(@"xml rpc error!");
NSLog( @"error result:%@", [result objectForKey:( NSString* ) kWSFaultString ]);
}
else /*no error; all's well*/ {
NSLog( @"result:%@", [result objectForKey:( NSString* ) kWSMethodInvocationResult ]);
}
// here's the output from the result
2/12/09 10:37:52 AM Ticket[25867] result:{
category = 0;
items = (
{
id = 6836;
price = "180.00";
title = "test1 string";
},
{
id = 6837;
price = "10.00";
title = "test2 string";
},
);
total = 20;
}
// and here's the debug result output
NSString * strresult = nil;
strresult = [result objectForKey:(NSString*) kWSDebugIncomingBody];
NSLog(@"kWSDebugIncomingBody : %@",strresult);


2/12/09 10:38:48 AM Ticket[25911] aResult : /WSDebugInBody -> <?xml version="1.0" encoding="UTF-8"?>
<methodResponse>
<params>
<param>
<value>
<struct>
<member>
<name>total</name>
<value>
<string>20</string>
</value>
</member>
<member>
<name>category</name>
<value>
<string>0</string>
</value>
</member>
<member>
<name>items</name>
<value>
<array>
<data>
<value>
<struct>
<member>
<name>title</name>
<value>
<string>test1 string</string>
</value>
</member>
<member>
<name>id</name>
<value>
<string>6836</string>
</value>
</member>
<member>
<name>price</name>
<value>
<string>180.00</string>
</value>
</member>
</struct></value>
<value>
<struct>
<member>
<name>title</name>
<value>
<string>test2 string</string>
</value>
</member>
<member>
<name>id</name>
<value>
<string>6837</string>
</value>
</member>
<member>
<name>price</name>
<value>
<string>10.00</string>
</value>
</member>
</struct></value>
</struct></value>
</param>
</params>
</methodResponse>