In this article we will look at a partial listing of the xmlintf unit and then write a program to demonstrate how to use DOM in Delphi. We began our discussion of this topic in the previous article. This is part three of a four-part series.
Delphi Wrapper Classes and XML - A Demonstration (Page 3 of 4 )
Earlier we created a program that loads an XML document into a memo component. In the following section we will create a program that will load an XML document into a DOM and then show the structure in a treeview, which incidentally is the only control in the component collection of Delphi that I think is useful for this kind of exercise.
Loading the document is very simple, as you've seen from the previous example, but showing it in a tree is another matter altogether. Place two treeview components on a form and then add two buttons. Call the treeviews tv and tv1 respectively. Then call the first button "Load" and the other one "Exit." On the form, add an opendialog component (available from the dialog tab) and an xmldocument component (available from the Internet tab).
First we start by defining some variables, procedures and functions. The listing also shows the components that is used in the application. It is a good place to verify what components you need to built the application itself: