Question

I am trying to parse an XML string in Xcode. It parse the string successfully, but after it gives error.

Here is the xml String, parsing code and error message. please guide me.

Thank you all in advance.

XML String.

<?xml version="1.0" encoding="utf-8"?>
<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><GetProductResponse xmlns="http://searchupc.com/"><GetProductResult>"productname","imageurl","producturl","price","currency","saleprice","storename"
"Nature's Way Kids Smart Omega-3 Vita Balls X 50 Caps","http://ecx.images-amazon.com/images/I/31A5BCa%2BFvL._SL160_.jpg","","22.04","USD","","N/A"
</GetProductResult></GetProductResponse></soap:Body></soap:Envelope>

the code returns for "GetProductResponse" and "soap:Body", then it gives error.

(void)parser:(NSXMLParser *)parser didEndElement:(NSString *)

NSLog(@"didEndElement() Element: ");
if(([elementName isEqualToString:@"GetProductResponse"]) ||
   ([elementName isEqualToString:@"soap:Body"]) ||
   ([elementName isEqualToString:@"soap:Envelope"])){

    NSLog(@"EOF Reached: %@",elementName);
    // we reach the end of product data string.
    return;
}

This is the error message:

Error Domain=NSXMLParserErrorDomain Code=111 "The operation couldn’t be completed. (NSXMLParserErrorDomain error 111.)"

Was it helpful?

Solution

I solved my problem myself. May be it helps some one else.

The error was with assigning XMLString to NSData. I was setting the NSData variable range as

,data = [data subdataWithRange:NSMakeRang(0,[data length] -1)];

This was incorrect.

I remove the " -1 ", Now it is working fine.

data = [data subdataWithRange:NSMakeRang(0,[data length] )];` 

Anyway Thank you of All.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top