I am trying to parse thE following string that i receive from my WebService using SOAP.. Since i am not able to parse the data i receive from my web service( of which i have no idea why.. please take a look here parsing XML using Soap Web Services) i am converting the data to an NSString and then using TOUCHXML to parse the string
NSString *theXML = [[NSString alloc]
initWithBytes: [webData mutableBytes]
length:[webData length]
encoding:NSUTF8StringEncoding];
the string that i get is
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<GetCategoryResponse xmlns="http://tempuri.org/">
<GetCategoryResult>
<Root>
<Record>
<catid>1</catid><catname>Hi</catname><catlogo>http://10.25.4.49/monsoonstore/Category/50X50.GIF</catlogo>
</Record>
</Root>
</GetCategoryResult>
</GetCategoryResponse>
</s:Body>
</s:Envelope>
since i am not able to get any parser to read the NSData i get from webservice i convert the above string to the following (ie. the exact xml i needed)
<Root><Record><catid>1</catid><catname>Hi</catname><catlogo>http://10.25.4.49/monsoonstore/Category/50X50.GIF</catlogo></Record></Root>
CXMLDocument *doc = [[CXMLDocument alloc] initWithXMLString:check options:0 error:nil];
NSArray *items = [doc nodesForXPath:@"//Root" error:nil];
for (CXMLElement *item in items)
{
NSLog(@"Root");
NSArray *titles = [item elementsForName:@"Record"];
for(CXMLElement *title in titles)
{
NSLog(@"Record");
break;
}
NSArray *categories = [item elementsForName:@"catid"];
for(CXMLElement *category in categories)
{
NSLog(@"catid");
break;
}
NSArray *artists = [item elementsForName:@"catname"];
for(CXMLElement *artist in artists)
{
NSLog(@"catname");
break;
}
.
.
.
.
The Root and Record logs get called while the catid never gets called.. what am i possibly doing wrong??