//我以前做过的一个可以提取csdn的xml数据的源码。
//可以去
http://iapollo.diy.163.com/mywork/delphi/xmlTRA.rar
//下载源文件看看。程序用到了ksSkin控件,xp效果的,没什么用。
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, xmldom, StdCtrls, Provider, Xmlxform, DB, DBClient, Grids,
DBGrids, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient,
IdHTTP, DBCtrls, KsHooks, KsForms, KsSkinForms, KsSkinEngine, KsEdits,
KsSkinEdits, KsControls, KsButtons, KsSkinButtons, KsLabels,
KsSkinLabels, KsSkinDBControls, KsGrids, KsSkinDBGrids, KsProgress,
KsSkinProgress;
type
TForm1 = class(TForm)
DataSource1: TDataSource;
ClientDataSet1: TClientDataSet;
xmlt: TXMLTransformProvider;
IdHTTP1: TIdHTTP;
Memo1: TDBMemo;
DataSource2: TDataSource;
ClientDataSet2: TClientDataSet;
XMLTransformProvider1: TXMLTransformProvider;
DBMemo1: TDBMemo;
OpenDialog1: TOpenDialog;
SeSkinEngine1: TSeSkinEngine;
SeSkinForm1: TSeSkinForm;
Button1: TSeSkinButton;
Edit1: TSeSkinEdit;
Button2: TSeSkinButton;
SeSkinDBText1: TSeSkinDBText;
SeSkinDBGrid1: TSeSkinDBGrid;
SeSkinDBGrid2: TSeSkinDBGrid;
SeSkinButton1: TSeSkinButton;
SeSkinLabel1: TSeSkinLabel;
SeSkinButton2: TSeSkinButton;
SaveDialog1: TSaveDialog;
spb: TSeSkinProgressBar;
SeSkinLabel2: TSeSkinLabel;
procedure Button2Click(Sender: TObject);
procedure SeSkinButton1Click(Sender: TObject);
procedure SeSkinButton2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure IdHTTP1Workbegin
(Sender: TObject;
AWorkMode: TWorkMode;
const AWorkCountMax: Integer);
procedure IdHTTP1Work(Sender: TObject;
AWorkMode: TWorkMode;
const AWorkCount: Integer);
procedure IdHTTP1WorkEnd(Sender: TObject;
AWorkMode: TWorkMode);
private
{ Private declarations }
public
{ Public declarations }
procedure refresh;
procedure setXMLfile(filename:String);
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.refresh;
begin
ClientDataSet1.Active:=false;
ClientDataSet1.Active:=true;
ClientDataSet2.Active:=false;
ClientDataSet2.Active:=true;
end;
procedure TForm1.setXMLfile(filename:String);
begin
xmlt.XMLDataFile:=filename;
XMLTransformProvider1.XMLDataFile:=filename;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
if openDialog1.Execute then
setXMLfile(opendialog1.FileName);
refresh;
end;
procedure TForm1.SeSkinButton1Click(Sender: TObject);
begin
close;
end;
procedure TForm1.SeSkinButton2Click(Sender: TObject);
begin
if SaveDialog1.Execute then
ClientDataSet1.SaveToFile(SaveDialog1.FileName,dfXML);
end;
procedure TForm1.Button1Click(Sender: TObject);
var
xmlpath:String;
begin
memo1.Clear;
xmlpath:='http_xml.xml';
memo1.Lines.Add(idhttp1.Get(Edit1.Text));
if fileExists(xmlpath) then
deleteFile(xmlpath);
memo1.Lines.SaveToFile(xmlpath);
setXMLfile(xmlpath);
refresh;
end;
procedure TForm1.IdHTTP1Workbegin
(Sender: TObject;
AWorkMode: TWorkMode;
const AWorkCountMax: Integer);
begin
spb.Position := 0;
spb.Max := AWorkcountMax;
end;
procedure TForm1.IdHTTP1Work(Sender: TObject;
AWorkMode: TWorkMode;
const AWorkCount: Integer);
begin
spb.Position := AWorkCount;
end;
procedure TForm1.IdHTTP1WorkEnd(Sender: TObject;
AWorkMode: TWorkMode);
begin
spb.Position:=0;
end;
end.