首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ Builder >

请教怎么将一棵树保存为XML

2012-02-24 
请问如何将一棵树保存为XML我现在只会从XML读入,不会保存为XML谢谢[解决办法]C/C++ codevoid __fastcall T

请问如何将一棵树保存为XML
我现在只会从XML读入,不会保存为XML
谢谢

[解决办法]

C/C++ code
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;} 

热点排行