0
<NewDataSet>
<Table>
<CaseId>743</CaseId>
<PartyId>11100550</PartyId>
<CartId>18</CartId>
</Table>
<Table>
<CaseId>742</CaseId>
<PartyId>11100549</PartyId>
<CartId>1148</CartId>
<BusinessID>19</BusinessID>
</Table>
</NewDataSet>
NSData* data = [xmlResponseData dataUsingEncoding:NSUTF8StringEncoding];
// NSXMLParser *XMLparser = [[NSXMLParser alloc] initWithData:data];
// [XMLparser setDelegate:self];
BOOL success;
if (XMLparser) // addressParser is an NSXMLParser instance variable
[XMLparser release];
XMLparser = [[NSXMLParser alloc] initWithData:data];
[XMLparser setDelegate:self];
[XMLparser setShouldResolveExternalEntities:YES];
success = [XMLparser parse]; // return value not used
// if not successful, delegate is informed of error
if(success)
NSLog(@"Sucess Parsed");
else
NSLog(@"Error Error Error!!!");
// NSLog(@"Parsed string : %@",valueForItem);
}
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName
namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName
attributes:(NSDictionary *)attributeDict {
if([elementName isEqualToString:@"NewDataSet"]) {
caseID_List = [[NSMutableArray alloc]init];
}
NSLog(@"Processing Element: %@", elementName);
if ([elementName isEqualToString:@"CaseId"]) {
}
}
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string {
if(!currentElementValue)
currentElementValue = [[NSMutableString alloc] initWithString:string];
else
[currentElementValue appendString:string];
NSLog(@"Processing Value: %@", currentElementValue);
}
- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName
namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName {
if([elementName isEqualToString:@"NewDataSet"])
return;
}
我只需要CaseId來存儲給定的XML。任何人都可以在這個簡單的解析中給我建議!如何解析簡單的xml
對我來說,它的循環!並獲取所有詳細信息
爲什麼不使用GDataXML解析器..它易於使用和解析任何種類的XML .. – vishy 2012-08-16 08:58:37
你能告訴我,如果你得到了你的問題的答案,因爲我在這裏處理同樣的問題 – ichanduu 2012-10-10 07:04:13