0
<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和Im解析這樣的:陣列陣列NSXML分析器IOS
- (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臺打印機,但是當IM試圖獲得這2個座標,但即時通訊只獲得最後一個座標兩次?問題是什麼。我在哪裏錯了你能幫我嗎? 在此先感謝..
你能找到答案嗎?如果是的話,你也可以告訴我。一直在尋找一種解析XML的方法,並顯示它們的子元素值名稱。 –