已经有了KissXML解析开源的库,解析的时候
1.在viewDidLoad里
NSString* url = @"http://124.205.53.122:8080/palmgo/NaviSv";
NSDictionary* request = [NSDictionarydictionaryWithObjectsAndKeys:@"help“,@"type”,nil];
[[NetManagershared] doRequest:urlrequest:request host:self];
2.
- (void)httpExecutorSucceeded:(NSHTTPURLResponse*)response data:(NSData*)data {
NSLog(@"FirstViewController httpExecutorSucceeded");
//把编码为 GB2312 的 NSData 转换为 NSString
//NSString *text = [Encode NSData2NSStringForGB2312:data];
//NSLog(@"%@", text);
NSData* newData = [Encode GB2312toUTF8ForNSDataXML:data];
NSString *text = [Encode NSData2NSStringForUTF8:newData];
//两种解析方法
//第一种 KissXml
SSXMLNode *selfNode = [[SSXMLNode alloc] initWithXMLContent:text];
NSLog(@"%@", text);
SSXMLNode *xml_title = [selfNode singleNodeWithNamePath:@"help/title"];
NSLog(@"%@",[xml_title attribute:@"innerText"]);
SSXMLNode *xml_head0 = [selfNode nodeWithNamePath:@"help/contents:0/head:0"];
NSLog(@"%@",[xml_head0 attribute:@"innerText"]);
SSXMLNode *xml_head1 = [selfNode nodeWithNamePath:@"help/contents:0/content:0"];
NSLog(@"%@",[xml_head1 attribute:@"innerText"]);
//第二种 NSXMLParser
// LoginXMLParser *parser=[[LoginXMLParser alloc] init];
// [parser parseXMLFileWithData:newData];
//
//
// NSMutableDictionary *test = [[parser currentRow] objectAtIndex:0];
//
//
// NSLog(@"%@",[test objectForKey:@"shortTitle"]);
}