I have problems regarding the output of the XMLReader , which should be able to parse any SOAP-Result into an NSDictionary.
When I go through the results I get the following:
Key: soapEnvelope, Value: {the rest of the xml-file to the end, with all tags, but it seems to be a long string}
What am I doing wrong here since I expected to get a NSDictionary with all of my XML-Tags as a key?
Edit: Since I´m working and trying to understand this since days, I may be totally in the wrong direction, so if possible... here´s my XML:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<GetData2Response xmlns="http://tempuri.org/">
<GetData2Result>
<NoOfObjectsDetected>1</NoOfObjectsDetected>
<RectanglesForPicture>
<Rectangle>
<Location>
<X>90</X>
<Y>14</Y>
</Location>
<Size>
<Width>352</Width>
<Height>352</Height>
</Size>
<X>90</X>
<Y>14</Y>
<Width>352</Width>
<Height>352</Height>
</Rectangle>
</RectanglesForPicture>
<ReturnMessage>Juhu!</ReturnMessage>
</GetData2Result>
</GetData2Response>
</soap:Body>
When I want to have Lets say NoOfObjectsDetected in an int - what exactly do I have to do? (It´s stupid, I know... but I´m lost atm... thx)
are u parsing with the help of NSXMLParser?? here is the method. create an mutable array to store the contents of xml. in the delegate methods do the following:
nsmutablearray noOfObjetcsArray; nsstring elementNameStr;
-(void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)atributeDict
{
if ([elementName isEqualToString:@"NoOfObjectsDetected"])
{
noOfObjetcsArray =[nsmutablearray alloc] initwithcapacity:0];
elementNameStr = elementName;
}
}
-(void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
{
if ([elementNameStr isEqualToString:@"NoOfObjectsDetected"])
{
[noOfObjetcsArray addObject:string];
}
}
when parsing is complete u will get the contents in the array. since u want it as an int value, wherever u use this value jus give:
[[noOfObjetcsArray objectAtIndex:0] intValue]
this will convert string to int value. thats the way u can get teh value. try it.
all the best :)
}