下面是解析器我寫..
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName
namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName
attributes:(NSDictionary *)attributeDict {
if([elementName isEqualToString:@"RESULTS"]) {
//Initialize the array.
//appDelegate.maps = [[NSMutableArray alloc] init];
}
else if([elementName isEqualToString:@"COLUMN"]) {
//Initialize the book.
amaps = [[MapDetails alloc] init];
dict = [[NSDictionary alloc] initWithDictionary:attributeDict];
if ([[attributeDict objectForKey:@"NAME"] isEqualToString:@"NAME"]) {
}
}
}
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
{
str123=[NSString stringWithFormat:@"%@",string];
}
// this delegate method is called if an error occurs in locating your current location
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error {
NSLog(@"STEP 3: Failed!!! Finding location : %@ ", error);
if (kCLErrorDenied) {
} else {
// We handle all non-CoreLocation errors here
}
}
- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName
namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName {
if([elementName isEqualToString:@"RESULTS"])
return;
if([elementName isEqualToString:@"COLUMN"])
{
amaps.NAME = [NSString stringWithString:str123];
NSLog(@"%@",amaps.NAME);
if ([[dict objectForKey:@"NAME"] isEqualToString:@"NAME"]) {
[arrName addObject:[NSString stringWithFormat:@"%@",amaps.NAME]];
NSLog(@"arr %@",arrName);
}
if ([[dict objectForKey:@"NAME"] isEqualToString:@"ANAME"]) {
[arrArabName addObject:[NSString stringWithFormat:@"%@",amaps.NAME]];
NSLog(@"arr %@",arrArabName);
}
if ([[dict objectForKey:@"NAME"] isEqualToString:@"YCOORD_WGS"]) {
[arrLatitude addObject:[NSString stringWithFormat:@"%@",amaps.NAME]];
NSLog(@"arr %@",arrLatitude);
}
if ([[dict objectForKey:@"NAME"] isEqualToString:@"XCOORD_WGS"]) {
[arrLongitude addObject:[NSString stringWithFormat:@"%@",amaps.NAME]];
NSLog(@"arr %@",arrLongitude);
}
}
}
正如你已經猜到,你可以用'NSXMLParser'。你有什麼問題? – user1118321 2012-07-30 18:05:15
你嘗試過的'NSXMLParser'代碼在哪裏?你是否遇到過'تسجيل - ترخيص'的unicode問題?否則,我會投票結束這個問題。 – Joe 2012-07-30 18:10:37
與unicode問題沒有概率..我面臨問題獲取COLUMN標記內的數據。例如,我需要使用SMXMLDocument .. <列NAME =「PHONE」> 4441303 .. im中的電話號碼,他們使用NSXMLPArser – Pras 2012-07-30 18:23:17