so, I have received a soap response from a service and now I need to parse it. I am getting stuck. For this response, I want to grab the “Gzk0P” value toward the bottom. See my parse method below the xml. thanks!
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://mysvc.myservice.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns2="http://xml.apache.org/xml-soap" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<ns1:createSubmissionResponse>
<return xsi:type="ns2:Map">
<item>
<key xsi:type="xsd:string">error</key>
<value xsi:type="xsd:string">OK</value>
</item>
<item>
<key xsi:type="xsd:string">link</key>
<value xsi:type="xsd:string">Gzk0P</value>
</item>
</return>
</ns1:createSubmissionResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict {
if ([elementName isEqualToString:@"key"]) {
NSString *title = [attributeDict valueForKey:@"value"];
NSString *test = @"";
}
}
You are doing wrong you cant access the values form attributed dict. attributed dict is used when values written in the same tag as attribute see this
lt key gt xsi:type=”xsd:string” value=”Gzk0P”>link lt /key gt
But here is condition is different, value is an separate tag in tag thats why you need to reach inside the value tag and in
foundCharactersmethod you can access that value.code some thing like this