Objective c 从SOAP响应解析组XML节点-目标C
我有以下来自SOAP响应的XML,我应该如何解析它Objective c 从SOAP响应解析组XML节点-目标C,objective-c,xml,soap,nsxmlparser,Objective C,Xml,Soap,Nsxmlparser,我有以下来自SOAP响应的XML,我应该如何解析它 <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soapenv:Body> <areaSearchRespo
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<areaSearchResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<areaSearchReturn xsi:type="ns1:QueryBean" xmlns:ns1="http://rpc.xml.coldfusion">
<details soapenc:arrayType="xsd:anyType[4]" xsi:type="soapenc:Array">
<details xsi:type="soapenc:string">photo1.jpg</data>
<details xsi:type="soapenc:int">1224</data>
<details xsi:type="soapenc:double">552.0</data>
<details xsi:type="soapenc:double">20.04</data>
</details>
<details soapenc:arrayType="xsd:anyType[4]" xsi:type="soapenc:Array">
<details xsi:type="soapenc:string">photo2.jpg</data>
<details xsi:type="soapenc:int">1234</data>
<details xsi:type="soapenc:double">632.0</data>
<details xsi:type="soapenc:double">34.05</data>
</details>
在我上面的didEndElement:method代码中,我总是将self.isNewRow的值设置为False(NO)
为什么呢
还有什么方法可以解析上述XML?
或
解析组节点的最佳方法是什么
提前谢谢 我把它解决了。我使用KissXML和xPath解析该XML。下面是代码,以防任何人在解析xml时遇到同样的问题
DDXMLDocument *doc = [[DDXMLDocument alloc] initWithData:data options:0 error:&err];
NSArray *areaSearchNode = [doc nodesForXPath:@"/soapenv:Envelope/soapenv:Body/areaSearchResponse/areaSearchReturn/details/" error:&err];
for(DDXMLDocument *node in areaSearchNode){
NSArray *newRoot = node.children;
DDXMLNode *photoURL = (DDXMLNode*) newRoot[0];
DDXMLNode *listingID = (DDXMLNode*) newRoot[1];
NSString *listingIDstr = [listingID stringValue];
DDXMLNode *priceFrom = (DDXMLNode*) newRoot[2];
NSString *price = [priceFrom stringValue];
DDXMLNode *latNode = (DDXMLNode*) newRoot[3];
NSString *lat = [latNode stringValue];
DDXMLNode *lonNode = (DDXMLNode*) newRoot[4];
NSString *lon = [lonNode stringValue];
DDXMLNode *bedroomType = (DDXMLNode*) newRoot[5];
NSString *bedroomTypestr = [bedroomType stringValue];
DDXMLNode *bathroomType = (DDXMLNode*) newRoot[6];
NSString *bathroomTypestr = [bathroomType stringValue];
// Here adding parsed data into class
IDSPropertyInfo *propertyInfo = [[IDSPropertyInfo alloc]
initWithPhotoURL:[photoURL stringValue]
listingID:[listingIDstr intValue]
priceFrom:[price doubleValue]
lat:[lat doubleValue]
lon:[lon doubleValue]
bedroomTypeID:[bedroomTypestr intValue]
bathroomTypeID:[bathroomTypestr intValue]];
}
//Now Add IDSPropertyInfo Class into NSMutableArray.
[self.propertyInfoArray addObject:propertyInfo];
DDXMLDocument *doc = [[DDXMLDocument alloc] initWithData:data options:0 error:&err];
NSArray *areaSearchNode = [doc nodesForXPath:@"/soapenv:Envelope/soapenv:Body/areaSearchResponse/areaSearchReturn/details/" error:&err];
for(DDXMLDocument *node in areaSearchNode){
NSArray *newRoot = node.children;
DDXMLNode *photoURL = (DDXMLNode*) newRoot[0];
DDXMLNode *listingID = (DDXMLNode*) newRoot[1];
NSString *listingIDstr = [listingID stringValue];
DDXMLNode *priceFrom = (DDXMLNode*) newRoot[2];
NSString *price = [priceFrom stringValue];
DDXMLNode *latNode = (DDXMLNode*) newRoot[3];
NSString *lat = [latNode stringValue];
DDXMLNode *lonNode = (DDXMLNode*) newRoot[4];
NSString *lon = [lonNode stringValue];
DDXMLNode *bedroomType = (DDXMLNode*) newRoot[5];
NSString *bedroomTypestr = [bedroomType stringValue];
DDXMLNode *bathroomType = (DDXMLNode*) newRoot[6];
NSString *bathroomTypestr = [bathroomType stringValue];
// Here adding parsed data into class
IDSPropertyInfo *propertyInfo = [[IDSPropertyInfo alloc]
initWithPhotoURL:[photoURL stringValue]
listingID:[listingIDstr intValue]
priceFrom:[price doubleValue]
lat:[lat doubleValue]
lon:[lon doubleValue]
bedroomTypeID:[bedroomTypestr intValue]
bathroomTypeID:[bathroomTypestr intValue]];
}
//Now Add IDSPropertyInfo Class into NSMutableArray.
[self.propertyInfoArray addObject:propertyInfo];