网络编程 | 站长之家 | 网页制作 | 图形图象 | 操作系统 | 冲浪宝典 | 软件教学 | 网络办公 | 邮件系统 | 网络安全 | 认证考试 | 系统进程
Firefox | IE | Maxthon | 迅雷 | 电驴 | BitComet | FlashGet | QQ | QQ空间 | Vista | 输入法 | Ghost | Word | Excel | wps | Powerpoint
asp | .net | php | jsp | Sql | c# | Ajax | xml | Dreamweaver | FrontPages | Javascript | css | photoshop | fireworks | Flash | Cad | Discuz!
当前位置 > 网站建设学院 > 网络编程 > Delphi
Tag:注入,存储过程,分页,安全,优化,xmlhttp,fso,jmail,application,session,防盗链,stream,无组件,组件,md5,乱码,缓存,加密,验证码,算法,cookies,ubb,正则表达式,水印,索引,日志,压缩,base64,url重写,上传,控件,Web.config,JDBC,函数,内存,PDF,迁移,结构,破解,编译,配置,进程,分词,IIS,Apache,Tomcat,phpmyadmin,Gzip,触发器,socket
网络编程:ASP教程,ASP.NET教程,PHP教程,JSP教程,C#教程,数据库,XML教程,Ajax,Java,Perl,Shell,VB教程,Delphi,C/C++教程,软件工程,J2EE/J2ME,移动开发
本月文章推荐
.将Dcom对象转换成Com+对象的一种.
.李维问答集之语言真的不重要吗?.
.数据表的二维表存储及定位.
.使用互斥对象让程序只运行一次.
.Delphi点滴.
.Delphi数据压缩处理(1).
.创建Photoshop式浮动窗口应用程序.
.Delphi4的Winsocket编程.
.软件开发的管理和控制.
.有关ADO专题.
.Borland的MIDAS技术.
.Delphi编码标准——窗体与数据模.
.将image的图片保存为JPG格式图片.
.如何通过COM接口得到实现该接口的.
.从当前的浏览器取得当前URL.
.修正XPMenu的两个Bug.
.动态数据库连接.
.怎样让程序延时.
.DELPHI的原子世界.
.根据时间日期格式从字符串中解析.

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

发表日期:2006-2-4


在delphi中使用xml文档有两种方法
使用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;
...
//本文为转贴,作者不详,仅供大家参考

上一篇:DELPHI基础开发技巧 人气:4056
下一篇:压缩图像文件并转换成BMP格式 人气:6036
浏览全部Delphi的内容 Dreamweaver插件下载 网页广告代码 祝你圣诞节快乐 2009年新年快乐