请问如何将一棵树保存为XML
我现在只会从XML读入,不会保存为XML
谢谢
[解决办法]
void __fastcall TOpenFileForm::SaveFolderList(WideString FileName){ TXMLDocument *xml = new TXMLDocument(NULL); /* <GetInfoSettings> <Folder> <List>bbbb</List> <List>aaaa</List> </Folder> <Ext> <List>cccc</List> <List>dddd</List> </Ext> </GetInfoSettings> */ xml->Active = true; xml->Encoding = "GB2312"; TXMLDocOptions options; options<<doNodeAutoIndent; xml->Options = options; xml->DocumentElement = xml->CreateNode(L"GetInfoSettings"); _di_IXMLNode rootnode = xml->DocumentElement; int n = ComboBox1->Items->Count; int i; _di_IXMLNode FolderListNode = rootnode->AddChild(L"Folder"); if(n != 0) { _di_IXMLNode list; for(i = 0; i < n; i++) { list = FolderListNode->AddChild(L"List"); list->SetText(WideString(ComboBox1->Items->Strings[i])); } } n = ComboBox2->Items->Count; _di_IXMLNode ExtListNode = rootnode->AddChild(L"Ext"); if(n != 0) { _di_IXMLNode list; for(i = 0; i < n; i++) { list = ExtListNode->AddChild(L"List"); list->SetText(WideString(ComboBox2->Items->Strings[i])); } } xml->SaveToFile(FileName); xml->Active = false; delete xml;}