sqlite 导出为 XML格式

前端之家收集整理的这篇文章主要介绍了sqlite 导出为 XML格式前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

- (IBAction)create:(id)sender
{
NSXMLElement *xmlelement = [NSXMLNode elementWithName:@"vote"];///////////////根结点
NSXMLDocument *doc = [[NSXMLDocument alloc] initWithRootElement:xmlelement];
for(int i =0; i < 4;i++){
NSXMLElement*stu = [NSXMLNodeelementWithName:@"Student \n"];
NSXMLElement*stuid = [NSXMLNode@"StudentID"*stuname = [NSXMLNode@"StudentNo"*stutel = [NSXMLNode@"LastName"*contact = [NSXMLNode@"contact"];
NSXMLElement *contactname = [@"Contactnsme"];
NSXMLElement *contactsex = [@"ContactSex"];
[xmlelement addChild:stu];
[stu addChild:stuid];
[stu addChild:stuname];
[stu addChild:stutel];

[stu addChild:contact];
[contact addChild:contactname];
[contact addChild:contactsex];

NSArray *arrid = [stu elementsForName:@"StudentID"];
NSArray *arrname = [stu @"StudentNo"];
NSArray *arrtel = [stu @"LastName"];
NSArray *arrconname = [contact @"Contactnsme"];
[[arrconname objectAtIndex:0] setStringValue@"hsdakhsjkahdkjsad"];////////在此给每个字段填冲数据
}
[doc setVersion@"1.0"];
[doc setCharacterEncoding@"UTF-8"];

NSData *xmldata = doc.XMLData;
NSSavePanel*oPanel = [NSSavePanelsavePanelNSString*startingDir = [[NSUserDefaultsstandardUserDefaults] objectForKey@"StartingDirectory"];
if (!startingDir)
startingDir = NSHomeDirectory();
NSString *str = [oPanel title];


if([oPanel runModalForDirectory:startingDir file:str] == NSOKButton)
{
NSLog(@"ok");
}
NSString *filename = [oPanel filename];
filename =[filename stringByAppendingString:@".xml"];


@"%@",filename);
[xmldata writeToFile:filename atomically:YES]; }

原文链接:https://www.f2er.com/sqlite/202651.html

猜你在找的Sqlite相关文章