频 道 直 达 - 新闻 - 读书 - 培训 - 教程 - 前沿 - 组网 - 系统应用 - 安全 - 编程 - 存储 - 操作系统 - 数据库 - 服务器 - 专题 - 产品 - 案例库 - 技术圈 - 博客 - BBS
51CTO.COM_中国领先的IT技术网站
找资料:

在delphi中使用xml文档有两种方法

作者: 51cto.com整理 出处:网络  (  ) 砖  (  ) 好  评论 ( ) 条  进入论坛
更新时间:2005-10-14 11:47
关 键 词:XML  Delphi
阅读提示:本文介绍在delphi中使用xml文档的两种方法

在delphi中使用xml文档有两种方法,一是使用delphi 内置的xml broker;一是使用msxml.dll 。

一  使用xml broker, 是delphi 内置的

例:
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;
...


发表
查看
我也说两句

匿名发表

(如果看不清请点击图片进行更换)


中 国 领 先 的 IT 技 术 网 站 ·
技 术 成 就 梦 想
·Java基础教程 (查看51847次)
·UML类图详解 (查看46438次)
·Java编程开发手册 (查看24908次)
·UML统一建模语言 (查看23911次)
·C#技术开发指南 (查看21990次)
·Java编程开发手册 (1195个砖)
·Java基础教程 (429个砖)
·C#技术开发指南 (304个砖)
·PB开发教程 (220个砖)
·.NET开发手册 (217个砖)
·Java编程开发手册 (653个好)
·Java基础教程 (569个好)
·.NET开发手册 (249个好)
·PB开发教程 (208个好)
·Delphi开发技术手册 (174个好)
订阅技术快讯
电子杂志下载
名称:网络安全精品应用黄皮书
简介:《2007精品网络安全黄皮书》包括了9个大类24个小类, 800余篇文章,内容包含了熊猫烧香病毒、DDOS攻击、ARP病等热点问题的介绍及解决方案。从病毒查杀、防范、系统、数据等各方面的安全设置到黑客技术的了解、防范,涉及到了安全应用的全部领域, 由浅至深内容全面。
名称:Vista精品应用黄皮书
简介:《Vista精品应用黄皮书》囊括了Vista的各方面内容。此次的精简版,是将里面的内容做了提取,便于用户下载和使用。内容包含了各种Vista的安装与实施、技巧与解析以及各种Vista相关学习文档和相关软件的安全下载。该电子书是了解和应用Vista人员必备的工具手册,并且也是第一本
名称:2006中国IT论坛精品集合
简介:本书由“51CTO论坛推广联盟”制作完成。书中所有内容均来自各联盟成员的论坛(网站)。制作本书的目的是为了集中大家的优势资源,将更多更精彩的内容带给广大技术爱好者。本书是联盟成立以来制作的第一本书。
关键字阅读
频道精选
主编信箱 热线:010-66476606 告诉我们您想看的:专题 文章
关于我们 | 诚聘英才 | 联系我们 | 网站大事 | 意见反馈 | 网站地图
Copyright©2005-2007 51CTO.COM 版权所有