<events>
<status>OK</status>
<name>20121203</name>
<descripcion></descripcion>
<url_IOS></url_IOS>
<printers>
<coordenadas_LAT>40.44702054203392</coordenadas_LAT>
<coordenadas_LON>-3.703991174697876</coordenadas_LON>
</printers>
<printers>
<coordenadas_LAT>40.448416693004596</coordenadas_LAT>
<coordenadas_LON>-3.7036800384521484</coordenadas_LON>
</printers>
</events>
==== 大家好,我有这个 XML,我正在解析:
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName attributes:(NSDictionary *)attributeDict
{
// the start of a 'booth' element is been encountered
if([elementName isEqualToString:@"events"])
{
self.tmpEvent = [[PublicPrivateEvent alloc] init];
}
}
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
{
currentElementValue = (NSMutableString *) [string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
}
- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
{
if ([elementName isEqualToString:@"coordenadas_LAT"]) {
tmpEvent.latitude =currentElementValue;
}
if([elementName isEqualToString:@"coordenadas_LON"])
{
tmpEvent.longtitude = currentElementValue ;
}
if([elementName isEqualToString:@"description"])
{
tmpEvent.description = currentElementValue;
}
if([elementName isEqualToString:@"url_IOS"])
{
tmpEvent.imgurlios6 = currentElementValue;
}
if([elementName isEqualToString:@"printers"])
{
[printers addObject:tmpEvent];
currentElementValue = nil;
}
if([elementName isEqualToString:@"status"])
{
[events addObject:tmpEvent];
currentElementValue = nil;
}
}
=== 我有 2 台打印机,但是当我试图获得这 2 个坐标时,我只获得了最后一个坐标两次?问题是什么。我哪里错了你能帮帮我吗?提前致谢..