title: Treeview save/load to xml too slow
body: <p>At the moment there are some 40,000 nodes in the treeview which is the standard TTreeView of XE6.
  The problem is that save/load takes long time (about 2 minutes) and the number of nodes is expected to grow in the future.</p>
  
  <p>What is your opinion on improving the speed? Any other way of save/load besides xml? Any other treeview component?</p>
  
  <p>Edit: Ok, the whole truth and nothing but truth. I just measured (using no fancy instrumentation, just one Mississippi, two Mississippi, ...)  the load/save time. Save is about 5 seconds and load is a bit less than 5 seconds. It just feels so sluggish and unresponsive that I had the impression that it took 2 minutes. :)
  Thanks</p>
  
  <p>Code:</p>
  
  <pre><code>procedure TTree.Save(aTreeView: TTreeView; aFilePath: String);
  var
    oTreeNode: TTreeNode;
    oXMLDocument: IXMLDocument;
    oXMLNode: IXMLNode;
    procedure ProcessTreeItem(aTreeNode: TTreeNode; aXMLNode: IXMLNode);
    var
      oTemp: IXMLNode;
    begin
      if (aTreeNode = nil) then Exit;
      oTemp := aXMLNode.AddChild('item');
      oTemp.Attributes['text'] := aTreeNode.Text;
      oTemp.Attributes['NodeID'] := TNode(aTreeNode.Data).ID;
      oTemp.Attributes['NodeType'] := TNode(aTreeNode.Data).NodeType;
      oTemp.Attributes['Selected'] := aTreeNode.Selected;
      aTreeNode := aTreeNode.getFirstChild;
      while aTreeNode &lt;&gt; nil do begin
        ProcessTreeItem(aTreeNode, oTemp);
        aTreeNode := aTreeNode.getNextSibling;
      end;
    end;
  begin
    oXMLDocument := NewXMLDocument;
    oXMLDocument.Options := [doNodeAutoIndent];
    oXMLNode := oXMLDocument.AddChild('xml');
    oTreeNode := aTreeView.TopItem;
    while oTreeNode &lt;&gt; nil do begin
      ProcessTreeItem(oTreeNode, oXMLNode);
      oTreeNode := oTreeNode.getNextSibling;
    end;
    oXMLDocument.SaveToFile(aFilePath);
  end;
  procedure TTree.Load(aTreeView: TTreeView; aFilePath: String);
  var
    oXMLNode: IXMLNode;
    oXMLDocument: IXMLDocument;
    procedure ProcessNode(aXMLNode: IXMLNode; aTreeNode: TTreeNode);
    var
      bExpanded: Boolean;
      oNodeData: TNode;
      oTemp: IXMLNode;
    begin
      if aXMLNode = nil then Exit;
      oNodeData := CreateNode(Integer(aXMLNode.Attributes['NodeID']), aXMLNode.Attributes['NodeType']);
      aTreeNode := aTreeView.Items.AddChildObject(aTreeNode, aXMLNode.Attributes['text'], oNodeData);
      aTreeNode.Selected := aXMLNode.Attributes['Selected'];
      oTemp := aXMLNode.ChildNodes.First;
      while oTemp &lt;&gt; nil do begin
        ProcessNode(oTemp, aTreeNode);
        oTemp := oTemp.NextSibling;
      end;
    end;
  begin
    aTreeView.Items.Clear;
    oXMLDocument := NewXMLDocument;
    oXMLDocument.LoadFromFile(aFilePath);
    oXMLNode := oXMLDocument.DocumentElement.ChildNodes.First;
    while oXMLNode &lt;&gt; nil do begin
      ProcessNode(oXMLNode, nil);
      oXMLNode := oXMLNode.NextSibling;
    end;
  end;
  </code></pre>