如果有原程序可以发到我的信箱
[email protected]
先谢过了!

解决方案 »

  1.   

    unit Linkup;interfaceuses
      SysUtils, Windows, Messages, Classes, Graphics, Controls,
      Forms, Dialogs, OleServer, MSXML2_TLB, Variants;type
      TLinkupXML = class (TComponent)
      private
        FXMLDoc: TDOMDocument30;
        function Orientation(var aNodeList: IXMLDOMNodeList): Boolean;
      public
        constructor Create(AOwner:TComponent);override;
        destructor Destroy; override;
        function Get_Value(aNodeIndex: Integer): string;
        function Get_Name(aNodeIndex: Integer): string;
        function NodeCount: Integer;
        function isLinkupXML: Boolean;
        procedure OpenXMLFile(aXMLFileName: String);
      end;
      procedure Register;implementationprocedure Register;
    begin
      RegisterComponents('Samples', [TLinkupXML]);
    end;{
    ********************************** TLinkupXML **********************************
    }constructor TLinkupXML.Create(AOwner: TComponent);
    begin
      inherited Create(AOwner);
      FXMLDoc := TDOMDocument30.Create(nil);
    end;destructor TLinkupXML.Destroy;
    begin
      inherited Destroy;
      FXMLDoc.Free;
    end;function TLinkupXML.Get_Name(aNodeIndex: Integer): string;
    var
      vNodeList: IXMLDOMNodeList;
    begin
      try
        if Orientation(vNodeList) then
        begin
          if aNodeIndex >= vNodeList.length then
            aNodeIndex := vNodeList.length - 1;
          if aNodeIndex < 0 then
            aNodeIndex := 0;
          Result := vNodeList.item[aNodeIndex].nodeName;  //返回Node名称
        end
        else  //不是linkupXML返回空
          Result := '';
      except
        Result := '';
      end;
    end;function TLinkupXML.Get_Value(aNodeIndex: Integer): string;
    var
      vNodeList: IXMLDOMNodeList;
    begin
      try
        if Orientation(vNodeList) then
        begin
          if aNodeIndex >= vNodeList.length then
            aNodeIndex := vNodeList.length - 1;
          if aNodeIndex < 0 then
            aNodeIndex := 0;
          Result := vNodeList.item[aNodeIndex].text;  //返回Node内容
        end
        else  //不是linkupXML返回空
          Result := '';
      except
        Result := '';
      end;
    end;function TLinkupXML.isLinkupXML: Boolean;
    var
      vNodeList: IXMLDOMNodeList;
    begin
      try
        if Orientation(vNodeList) then
          Result := True
        else
          Result := False;
      except
        Result := False;
      end;
    end;function TLinkupXML.NodeCount: Integer;
    var
      vNodeList: IXMLDOMNodeList;
    begin
      try
        if Orientation(vNodeList) then
          Result := vNodeList.length
        else
          Result := -1;
      except
        Result := -1;
      end;
    end;procedure TLinkupXML.OpenXMLFile(aXMLFileName: String);
    begin
      FXMLDoc.DefaultInterface.async := False;
      FXMLDoc.DefaultInterface.load(aXMLFileName);
    end;function TLinkupXML.Orientation(var aNodeList: IXMLDOMNodeList): Boolean;
    begin
      try
        //aNodeList := FXMLDoc.DefaultInterface.selectNodes('linkup');
        aNodeList := FXMLDoc.DefaultInterface.selectNodes('GFLOWASSISTANTINTERFACE');
        aNodeList := aNodeList.item[0].childNodes;
        if aNodeList.length > 0 then
        begin
          Result := True
        end
        else
          Result := False;
      except
        Result := False;
      end;
    end;
    end.
    这是我写的一个控件...
      

  2.   

    这段代码用了 MS 的 XML 解析工具 MSXML3.0如果你的操作系统是2000以上,那以经有了,如果有Ie6+sp2后也有了在你的Delphi中安装ActiveX控件,找MSXML安装入IDE开发环境就可以了
      

  3.   

    以上代码是 “静”态 生成TDOMDocument30对象的你也可以用“动”态的 CreateObj ....