🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.delphi.xml
2 messages
2 total messages Started by Guthrie Ward Sat, 17 May 2008 20:01
XML & TreeView
#172
Author: Guthrie Ward
Date: Sat, 17 May 2008 20:01
36 lines
1928 bytes
Hi Delphi'ers

After a long hiatus from programming (doing a bit of travelling), I'm trying 
to get back into the swing of thing with an XML driven application.  The 
application's XML structure will be as follows:

<Contacts>
   <Contact>
      <Name>Allan Moore</Name>
      <Age>36</Age>
      <Numbers>
         <Number>0208 987 6543</Number>
         <Number>0791 123 4567</Number>
      </Numbers>
      ...
   </Contact>
   <Contact>
      <Name>Jim Lee</Name>
      <Age>27</Age>
      <Numbers>
         <Number>0208 987 6543</Number>
         <Number>0791 123 4567</Number>
      </Numbers>
      ...
   </Contact>
</Contacts>

What I'm having problems with is getting specific XML data into a TreeView 
(All the Names of Contacts) under a Root Node.  And then using the 
TreeView's OnChange Event to display the Contact's additional information 
TEdits.

Thanks in advance.

Regards
Gus 
Re: XML & TreeView
#173
Author: Ronald Hoek
Date: Tue, 20 May 2008 11:20
44 lines
1742 bytes
Hello Guthrie,

I'm suspecting you want to do something like the following:

procedure TMyForm.LoadTreeview(const aXML: string);
var
  I: Integer;
  tn: TTreeNode;
begin
  FContacts := LoadContactFromXML(aXML);

  tv.Items.BeginUpdate;
  try
    tv.Items.Clear;
    for I := 0 to Contacts.Count - 1 do
    begin
      tn := tv.Items.Add(nil, Contacts[I].Name);
      tn.Data := Pointer(Contacts[I]);
    end;
  finally
    tv.Items.BeginUpdate;
  end;
end;

procedure TMyForm.OntvChange(Sender: TObject);
var
  _Cont: IXMLContact;
begin
  _Cont := IXMLContact((Sender as TTreeView).Selected.Data);
  // Fill edits at this point
end;


Use the XML-databinding tool, to create a Pascal binding for the XML



-- 
Regards,

Ronald Hoek

Applicationdevelopper
ComponentAgro B.V.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads