I am new to GDataXMLNode and xml namespaces.
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Body>
<ns1:StockDetails xmlns:ns1="urn:WinRetail:TestWebService">
<ttStockDetail>
<ttStockDetailRow>
<iconname>Levels.png</iconname>
<screenlabel>Inhand</screenlabel>
<detail>Product Detail</detail>
</ttStockDetailRow>
<ttStockDetailRow>
<iconname>Levels.png</iconname>
<screenlabel>In transit</screenlabel>
<detail>0</detail>
</ttStockDetailRow>
</ttStockDetail>
<resultstring>OK</resultstring>
</ns1:StockDetails >
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
How to parse this xml with namespaces using GDataXMLNode in Xcode? I don't want to use path. I want to get the element list in an array and then loop through it with a specific condition. I am unable to get the element list for 'StockDetails'.
Here is my code:
NSError *error;
GDataXMLDocument *xmlDocument = [[GDataXMLDocument alloc]initWithXMLString:fileContents options:0 error:&error];
NSDictionary *myNS = [NSDictionary dictionaryWithObjectsAndKeys: @"schemas.xmlsoap.org/soap/envelope/";, @"ns1", @"w3.org/2001/XMLSchema-instance";, @"ns2",,nil];
NSArray *tempArray = [xmlDocument.rootElement nodesForXPath:@"//ns1:Envelope" namespaces:myNS error:&error];
NSLog(@"%@",tempArray);
Please help.