Home arrow Delphi-Kylix arrow Page 3 - Delphi Wrapper Classes and XML
DELPHI-KYLIX

Delphi Wrapper Classes and XML


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.

Author Info:
By: David Web
Rating: 5 stars5 stars5 stars5 stars5 stars / 7
November 17, 2008
TABLE OF CONTENTS:
  1. · Delphi Wrapper Classes and XML
  2. · XML Properties, Methods, and Interface
  3. · A Demonstration
  4. · Second Part of Code

print this article
SEARCH DEVARTICLES

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).

Below is a listing for the entire application:


unit Unit1;


interface


uses

Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

Dialogs, xmldom, XMLIntf, msxmldom, XMLDoc, StdCtrls, ComCtrls;


type

TForm1 = class(TForm)

xd: TXMLDocument;

tv: TTreeView;

Button1: TButton;

Button4: TButton;

od: TOpenDialog;

tv1: TTreeView;

procedure Button4Click(Sender: TObject);

procedure FormCreate(Sender: TObject);

procedure tv1DblClick(Sender: TObject);

procedure Button1Click(Sender: TObject);

private

procedure DOMShow(Anode: IXMLNode; TNode: TTreeNode);

{ Private declarations }

public

fn:string;

{ Public declarations }

end;

const

IMG_NODE_ROOT = 0;

IMG_NODE_CLOSED = 1;

IMG_NODE_OPEN = 2;

IMG_NODE_ROOT2 = 3;

IMG_NODE_CLOSED2 = 4;

IMG_NODE_OPEN2 = 5;

var

Form1: TForm1;


implementation


{$R *.dfm}


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:


procedure TForm1.Button4Click(Sender: TObject);

begin

close;

end;


blog comments powered by Disqus
DELPHI-KYLIX ARTICLES

- Loading an XML Document into the DOM
- Delphi Wrapper Classes and XML
- Delphi and the DOM
- Delphi and XML
- Internet Access: Client Service
- Finishing the Client for an Internet Access ...
- The Client for an Internet Access Control Ap...
- User Management for an Internet Access Contr...
- Important Procedures for an Internet Access ...
- Server Code for an Internet Access Control A...
- Constructing the Interface for an Internet A...
- Building a Server Application for an Interne...
- Building an Internet Access Control Applicat...
- Client Dataset: Working with Data Packets an...
- Using the Client Dataset in an N-Tiered Appl...

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials