Code:
<?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>
<GetStationsResponse xmlns="http://www.example.com/">
<GetStationsResult>
<xs:schema xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="NewDataSet">
<xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="Stations">
<xs:complexType>
<xs:sequence>
<xs:element name="ID" type="xs:decimal" minOccurs="0"/>
<xs:element name="NAME" type="xs:string" minOccurs="0"/>
<xs:element name="DESCRIPTION" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
<diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
<NewDataSet xmlns="">
<Stations diffgr:id="Stations1" msdata:rowOrder="0">
<ID>129</ID>
<NAME>Station 1</NAME>
<DESCRIPTION>Station 1</DESCRIPTION>
</Stations>
<Stations diffgr:id="Stations2" msdata:rowOrder="1">
<ID>128</ID>
<NAME>Station 2</NAME>
</Stations>
</NewDataSet>
</diffgr:diffgram>
</GetStationsResult>
</GetStationsResponse>
</soap:Body>
</soap:Envelope>
I want for All <Stations> tag
Code:
-(void) grabStationData:(NSData *)responseData {
if (stationEntries) {
[self.stationEntries removeAllObjects];
}
// Initialize the blogEntries MutableArray that we declared in the header
self.stationEntries = [[[NSMutableArray alloc] init] autorelease];
// Create a new rssParser object based on the TouchXML "CXMLDocument" class, this is the
// object that actually grabs and processes the RSS data
CXMLDocument *rssParser = [[CXMLDocument alloc] initWithData:responseData options:0 error:nil];
//CXMLDocument *rssParser = [[CXMLDocument alloc] initWithContentsOfURL:url options:0 error:nil];
NSLog(@"rssParser %@",rssParser);
//NSLog(@"url %@",url);
// Create a new Array object to be used with the looping of the results from the rssParser
NSArray *resultNodes = NULL;
NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:
@"http://www.example.com/",
@"tempuriStation",
nil];
// Set the resultNodes Array to contain an object for every instance of an node in our RSS feed
//resultNodes = [rssParser nodesForXPath:@"//GetImagesResult" error:nil];
resultNodes = [rssParser nodesForXPath:@"//tempuriStation:GetStationsResult" namespaceMappings:dict error:nil];
// Loop through the resultNodes to access each items actual data
for (CXMLElement *resultElement in resultNodes) {
// Create a temporary MutableDictionary to store the items fields in, which will eventually end up in blogEntries
NSMutableDictionary *blogItem = [[[NSMutableDictionary alloc] init] autorelease];
// Create a counter variable as type "int"
int counter;
// Loop through the children of the current node
for(counter = 0; counter < [resultElement childCount]; counter++) {
//[resultElement initWithXMLString:@""];
NSString *strValue = [[resultElement childAtIndex:counter] stringValue];
//strValue = [strValue stringByReplacingOccurrencesOfString:@"\n" withString:@""];
NSString *strName = [[resultElement childAtIndex:counter] name];
if ([resultNodes containsObject:@""] || resultNodes == nil || resultElement == nil || [resultElement isEqual:@""] || [resultElement children] == nil) {
NSLog(@"Null Object");
}
else {
if (strValue && strName) {
// Add each field to the blogItem Dictionary with the node name as key and node value as the value
[blogItem setObject:[[resultElement childAtIndex:counter] stringValue] forKey:[[resultElement childAtIndex:counter] name]];
}
}
}
// Add the blogItem to the global blogEntries Array so that the view can access it.
//[self.imagesEntries setObject:[blogItem copy] forKey:@"text"];
[self.stationEntries addObject:[blogItem copy]];
NSLog(@"Station Image Entries %@",self.stationEntries);
}
//[appDelegate hideActivity:self];
//[[rssParser retain] release];
}