在delphi中使用xml文档有两种方法,一是使用delphi 内置的xml broker;一是使用msxml.dll 。
例:
unit showxml;
interface
uses classes httpapp db dbclient midas
xmlbrokr webcomp miditems;
type
tcustomshowxmlbutton = class(txmlbutton iscriptcomponent)
protected
xmlmethodname: string;
{ iscriptcomponent }
procedure addelements(addintf: iaddscriptelements);
function getsubcomponents: tobject;
{ iwebcontent implementation }
function implcontent(options: twebcontentoptions;
parentlayout: tlayout): string; override;
end;
tshowxmlbutton = class(tcustomshowxmlbutton)
public
constructor create(aowner: tcomponent); override;
published
property custom;
property style;
property stylerule;
property caption;
property xmlbroker;
property xmluseparent;
end;
tshowdeltabutton = class(tcustomshowxmlbutton)
public
constructor create(aowner: tcomponent); override;
published
property custom;
property style;
property stylerule;
property caption;
property xmlbroker;
property xmluseparent;
end;
implementation
uses sysutils midprod;
resourcestring
sshowxml = 'show xml';
sshowdelta = 'show delta';
procedure tcustomshowxmlbutton.addelements(
addintf: iaddscriptelements);
begin
addintf.addincludefile('xmlshow.js');
end;
function tcustomshowxmlbutton.getsubcomponents: tobject;
begin
result := nil;
end;
function tcustomshowxmlbutton.implcontent(options: twebcontentoptions;
parentlayout: tlayout): string;
var
attrs: string;
intf: ilayoutwebcontent;
formvarname: string;
rowsetvarname: string;
begin
addquotedattrib(attrs 'name' name);
addquotedattrib(attrs 'style' style);
addquotedattrib(attrs 'class' stylerule);
addquotedattrib(attrs 'value' self.caption);
addcustomattrib(attrs custom);
if assigned(xmldata.xmlbroker) then
begin
formvarname := xmldata.xmlbroker.submitformvarname;
rowsetvarname := xmldata.xmlbroker.rowsetvarname(nil); // row row set var name
end;
if not (conoscript in options.flags) then
result :=
format(''#13#10
[attrs rowsetvarname xmlmethodname sxmlreadyvar])
else
result :=
format(''#13#10
[attrs]);
if assigned(parentlayout) and parentlayout.getinterface(ilayoutwebcontent intf) then
result := intf.layoutbutton(result getlayoutattributes);
end;
{ tshowxmlbutton }
constructor tshowxmlbutton.create(aowner: tcomponent);
begin
inherited;
defaultcaption := sshowxml;
xmlmethodname := 'root';
end;
{ tshowdeltabutton }
constructor tshowdeltabutton.create(aowner: tcomponent);
begin
inherited;
defaultcaption := sshowdelta;
xmlmethodname := 'getdelta()';
end;
二 使用msxml.dll
例:
....
procedure tdhedform.openbtnclick(sender: tobject);
var
pvin : olevariant;
prompt : olevariant;
begin
pvin := '';
prompt := true;
dhtmledit1.loaddocument(pvin prompt);
end;
procedure tdhedform.savebtnclick(sender: tobject);
var
vo vb : olevariant;
begin
vo := dhtmledit1.currentdocumentpath;
if (vo <> '') then
begin
vb := false;
end
else
begin
vo := '';
vb := true;
end;
dhtmledit1.savedocument(vo vb);
end;
procedure tdhedform.saveasclick(sender: tobject);
var
vo vb : olevariant;
begin
vo := '';
vb := true;
dhtmledit1.savedocument(vo vb);
end;
...
Java Asp PHP .Net XML C/C++ CGI VB Jsp J2ee J2se J2me EJB Servlet Tomcat Resin Struts Weblogic Eclipse ANT GUI JMS Web servise IDEA Webphere Hibernate Spring Jboss Applet Swing Socket Javamail Perl Ajax P2P 安全 模式 框架 测试 开源 游戏
Windows XP Windows 2000 Windows 2003 Windows Me Windows 9.x Linux UNIX 注册表 操作系统 服务器 应用服务器