<root>
<setting>
<title>EventOn</title>
<layout>tile</title>
<headerStyle>Banner</headerStyle>
<color>颜色值</color>
<date>2013-02-13</date>
<location>位置</location>
</setting>
<!--主菜单 -->
<moduleid="mainmenu"title="首页sdfsdfsd"icon="custom_icon.png">
<item="地图ssfdafs"="close"target="EOMapViewController"/>
="标题2"="ItemViewController"="标题3"="itemImage"/>
</module>
<moduleid="map"title"地图"locationName豪成大厦3A02"latitude""longitude>
</module>
</root>
#import"TBXML.h"
@interfaceXXXClass :NSObject<NSXMLParserDelegate>
加入委托代理NSXMLParserDelegate
加载setting.xml
NSError*error;
TBXML*tbxml = [TBXMLnewTBXMLWithXMLFile:@"setting.xml"error:&error];
TBXMLElement*rootElement = tbxml.rootXMLElement;
if(error) {
NSLog(@"%@ %@",[errorlocalizedDescription],[erroruserInfo]);
}else{
TBXMLElement*element = [childElementNamed:@"module"parentElement:rootElement];
[selfdealMoudle:element];
}
解析module结点信息
- (void) dealMoudle:(TBXMLElement*)element{
do{
NSString*value = [valueOfAttributeNamed:@"id"forElement:element];
if([valueisEqualToString:@"mainmenu"]){
[dealMainMenuMoudle:element];
}
@"map"]){
}
}while((element = element->nextSibling));
}
- (void) dealMainMenuMoudle:(TBXMLElement*)_element{
@"item"parentElement:_element];
self.mainMenuArray= [[NSMutableArrayalloc]init];
self.mainMenuTitle= [TBXMLvalueOfAttributeNamed:@"title"forElement:_element];
do{
NSMutableDictionary*item = [[NSMutableDictionaryalloc]init];
[itemsetObject:[@"title"forElement:element]forKey:@"title"];
[item@"icon"@"icon"];
[item@"target"@"target"];
[mainMenuArrayaddObject:item];
}nextSibling));
}
好了,代码暂时就这么多,做个记录