在我的iOS應用程序中,我嘗試使用NSXMLParser解析下面的xml。我可以在iOS5中成功解析這個xml,但在iOS6中解析器沒有進入parserdidStartElement。在iOS6 parserDidStartDocument被成功調用,但沒有進入任何其他解析器委託方法..是否有任何問題與XML格式?我怎樣才能解決這個問題..NSXMLParser在iOS5中工作正常,但在iOS6中不工作
<RESULTS>
<ROW>
<COLUMN NAME="NAME">Test1</COLUMN>
<COLUMN NAME="ANAME">testing xml1</COLUMN>
<COLUMN NAME="PHONE">4470111</COLUMN>
<COLUMN NAME="REMARKS"/>
<COLUMN NAME="XCOORD_DMS">227901.58873387</COLUMN>
<COLUMN NAME="YCOORD_DMS">391872.68493206</COLUMN>
<COLUMN NAME="XCOORD_WGS">51.49367618</COLUMN>
<COLUMN NAME="YCOORD_WGS">25.27912682</COLUMN>
</ROW>
<ROW>
<COLUMN NAME="NAME">Test2</COLUMN>
<COLUMN NAME="ANAME">testing xml2</COLUMN>
<COLUMN NAME="PHONE">4258444</COLUMN>
<COLUMN NAME="REMARKS"/>
<COLUMN NAME="XCOORD_DMS">229608.71442946</COLUMN>
<COLUMN NAME="YCOORD_DMS">386848.18818915</COLUMN>
<COLUMN NAME="XCOORD_WGS">51.51051535</COLUMN>
<COLUMN NAME="YCOORD_WGS">25.23373805</COLUMN>
</ROW>
</RESULTS>
這是代碼..
- (void) initView:(JsonObject *) pageMenu{
appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
NSURL* url = [NSURL URLWithString:@"http://www.test.in/test.xml"];
NSXMLParser* parser = [[NSXMLParser alloc] initWithContentsOfURL:url];
[parser setDelegate:self];
[parser parse];
[parser release];
}
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName
namespaceURI:(NSString *)namespaceURI
qualifiedName:(NSString *)qName
attributes:(NSDictionary *)attributeDict{
NSLog (@"I have started");
}
- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName
namespaceURI:(NSString *)namespaceURI
qualifiedName:(NSString *)qName{
NSLog (@"I have started");
}
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string{
NSLog (@"I have started");
}
-(void) parserDidStartDocument:(NSXMLParser *)parser {
NSLog (@"I have started");
}
-(void) parserDidEndDocument: (NSXMLParser *)parser {
NSLog (@"I have started");
}
你能顯示一些代碼嗎? –
Phillipe ..我已經爲你粘貼了一些代碼..如果我使用其他簡單的xmls它會進入所有的解析器代表..問題只是與xml形式..但不知道如何在iOS6中完美工作 – Pras