我正在尝试在 Xcode 中解析 XML 字符串。它成功地解析了字符串,但在它给出错误之后。
这是xml字符串,解析代码和错误消息。请指导我。
谢谢大家。
XML 字符串。
<?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>
代码返回“GetProductResponse”和“soap:Body”,然后给出错误。
(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;
}
这是错误消息:
错误域 = NSXMLParserErrorDomain 代码 = 111 “操作无法完成。(NSXMLParserErrorDomain 错误 111。)”