title: Binding an XML node to a Tree view node
body: <p>I want to browse through XML using a TTreeView. To associate the treeview nodes with the XML nodes with attributes I used the following syntax:</p>
  
  <pre><code>var tv: TTreeView; tn1, tn2: TTreeNode; xn: IXMLNode;
  
  if xn.AttributeNodes.Count &gt; 0 then
    tn2 := tv.Items.AddChildObject( tn1, xn.NodeName, @xn )
  else
    tn2 := tv.Items.AddChild( tn1, xn.NodeName );
  </code></pre>
  
  <p>.. and later in the program:</p>
  
  <pre><code>var  tv: TTreeView; pxn: ^IXMLNode; i: integer;
  
  pxn := tv.Selected.Data;
  for i := 0 to iXML.AttributeNodes.Count-1 do
    ShowMessage ( pxn^.AttributeNodes[i].LocalName + ' = ' +
                  pxn^.AttributeNodes[i].Text );
  </code></pre>
  
  <p>which results in an exception.. As far as I can figure out this has to do with the fact that I'm point to an interface instead of an object. </p>
  
  <p>Is it possible to reference the actual object of the XML instead of the interface? 
  What will happen with this reference if new XML nodes are inserted in or deleted from the tree?</p>
  
  <p>Or is there another straight forward solution?</p>
  
  <p>All help appreciated!</p>