Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

marcio.theis

Abrindo Arquivos Xml...

Recommended Posts

Precisei um dia de uma programa para abrir arquivos XML, procurei na internet somente achei programas que demoravam demais para abrir, então decidi desenvolver o meu programa para abrir os arquivos.

O que ele faz é criar tudo dinamicamente, ou seja, pode abrir quantos arquivos desejar, e permite que seja aplicado filtros sobre os registros. Não apliquei nenhuma "frescura" a mais pois não era necessáio, no caso segue os fontes se alguém quiser mexer e incrementar, não comentei os fontes, se tiver alguma dúvida, é só perguntar:

Imagem Postada

 

Arquivo DFM:

object frmPrincipal: TfrmPrincipal	Left = 237	Top = 103	Width = 696	Height = 480	Caption = 'Abre XML'	Color = clBtnFace	Font.Charset = DEFAULT_CHARSET	Font.Color = clWindowText	Font.Height = -11	Font.Name = 'MS Sans Serif'	Font.Style = []	OldCreateOrder = False	PixelsPerInch = 96	TextHeight = 13	object Panel1: TPanel	  Left = 0	  Top = 0	  Width = 688	  Height = 41	  Align = alTop	  TabOrder = 0	  object btnAbrir: TBitBtn		Left = 8		Top = 8		Width = 75		Height = 25		Caption = 'Abrir'		TabOrder = 0		OnClick = btnAbrirClick	  end	  object Panel2: TPanel		Left = 512		Top = 1		Width = 175		Height = 39		Align = alRight		BevelOuter = bvNone		TabOrder = 1		object btnFecharAba: TBitBtn		  Left = 19		  Top = 7		  Width = 75		  Height = 25		  Caption = 'Fechar Aba'		  TabOrder = 0		  OnClick = btnFecharAbaClick		end		object btnSair: TBitBtn		  Left = 94		  Top = 7		  Width = 75		  Height = 25		  Caption = 'Sair'		  TabOrder = 1		  OnClick = btnSairClick		end	  end	end	object PageControl1: TPageControl	  Left = 0	  Top = 41	  Width = 688	  Height = 412	  Align = alClient	  TabOrder = 1	end	object OpenDialog: TOpenDialog	  DefaultExt = '*.xml'	  Filter = 'Arquivos XML|*.xml'	  Left = 152	  Top = 72	end  end
Arquivo .PAS

unit fPrincipal;    interface    uses	Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,	Dialogs, DB, DBClient, Grids, DBGrids, StdCtrls, Buttons, ExtCtrls,	ComCtrls;    type	TfrmPrincipal = class(TForm)	  OpenDialog: TOpenDialog;	  Panel1: TPanel;	  btnAbrir: TBitBtn;	  PageControl1: TPageControl;	  Panel2: TPanel;	  btnFecharAba: TBitBtn;	  btnSair: TBitBtn;	  procedure btnAbrirClick(Sender: TObject);	  procedure btnFecharAbaClick(Sender: TObject);	  procedure btnSairClick(Sender: TObject);	private	  { Private declarations }	  procedure BotaoClick(Sender: TObject);	public	  { Public declarations }	end;    var	frmPrincipal: TfrmPrincipal;    implementation    {$R *.dfm}    procedure TfrmPrincipal.btnAbrirClick(Sender: TObject);  var	  cliente: TClientDataSet;	  clienteSource: TDataSource;	  grid: TDBGrid;	  tabSheet: TTabSheet;	  painel: TPanel;	  edit: TEdit;	  botao: TBitBtn;	  lbl: TLabel;  begin  if OpenDialog.Execute then	  begin	  tabSheet:=TTabSheet.Create(PageControl1);	  tabSheet.Parent:=PageControl1;	  tabSheet.PageControl:=PageControl1;	  tabSheet.Caption:=ExtractFileName(OpenDialog.FileName);	  PageControl1.ActivePage:=tabSheet;  	  painel:=TPanel.Create(tabSheet);	  painel.Parent:=tabSheet;	  painel.Align:=alTop;	  painel.Caption:='';	  painel.Height:=30;	  painel.BevelOuter:=bvNone;  	  edit:=TEdit.Create(painel);	  edit.Parent:=painel;	  edit.Text:='Filtro';	  edit.CharCase:=ecUpperCase;	  edit.Width:=225;	  edit.Left:=10;	  edit.Top:=5;  	  botao:=TBitBtn.Create(painel);	  botao.Parent:=painel;	  botao.Caption:='Filtrar';	  botao.Width:=75;	  botao.Left:=240;	  botao.Top:=3;	  botao.OnClick:=BotaoClick;  	  lbl:=TLabel.Create(painel);	  lbl.Parent:=painel;	  lbl.Caption:='0';	  lbl.Left:=400;	  lbl.Top:=10;  	  cliente:=TClientDataSet.Create(Self);  	  clienteSource:=TDataSource.Create(Self);	  clienteSource.DataSet:=cliente;  	  grid:=TDBGrid.Create(tabSheet);	  grid.Parent:=tabSheet;	  grid.Align:=alClient;	  grid.DataSource:=clienteSource;  	  cliente.FileName:=OpenDialog.FileName;	  cliente.Open;	  lbl.Caption:=FormatFloat('###,###,###',cliente.RecordCount) + ' registros.';	  end;  end;    procedure TfrmPrincipal.BotaoClick(Sender: TObject);  var	  x, y, totalReg: integer;	  aux: string;  begin  totalReg:=0;    for x:=0 to PageControl1.ActivePage.ComponentCount - 1 do	  if PageControl1.ActivePage.Components[x].ClassType = TPanel then		  for y:=0 to (PageControl1.ActivePage.Components[x] as TPanel).ComponentCount - 1 do			  if (PageControl1.ActivePage.Components[x] as TPanel).Components[y].ClassType = TEdit then				  aux:=((PageControl1.ActivePage.Components[x] as TPanel).Components[y] as TEdit).Text;    for x:=0 to PageControl1.ActivePage.ComponentCount - 1 do	  begin	  if PageControl1.ActivePage.Components[x].ClassType = TDBGrid then		  begin		  (PageControl1.ActivePage.Components[x] as TDBGrid).DataSource.DataSet.Filtered:=False;		  if aux <> '' then			  begin			  (PageControl1.ActivePage.Components[x] as TDBGrid).DataSource.DataSet.Filter:=aux;			  (PageControl1.ActivePage.Components[x] as TDBGrid).DataSource.DataSet.Filtered:=True;			  end;		  totalReg:=(PageControl1.ActivePage.Components[x] as TDBGrid).DataSource.DataSet.RecordCount;		  end;	  end;    for x:=0 to PageControl1.ActivePage.ComponentCount - 1 do	  if PageControl1.ActivePage.Components[x].ClassType = TPanel then		  for y:=0 to (PageControl1.ActivePage.Components[x] as TPanel).ComponentCount - 1 do			  if (PageControl1.ActivePage.Components[x] as TPanel).Components[y].ClassType = TLabel then				   ((PageControl1.ActivePage.Components[x] as TPanel).Components[y] as  TLabel).Caption:=FormatFloat('###,###,###',totalReg) + ' registros.';  end;    procedure TfrmPrincipal.btnFecharAbaClick(Sender: TObject);  begin  if PageControl1.ActivePage <> nil then	  PageControl1.ActivePage.Destroy;  end;    procedure TfrmPrincipal.btnSairClick(Sender: TObject);  begin  close;  end;    end.
E ainda...

Fiz ele somente abrindo este formato de XML:

<?xml version="1.0" standalone="yes"?>  <DATAPACKET Version="2.0">  <METADATA>  <FIELDS>  <FIELD attrname="CODIGO" fieldtype="r8"/>  <FIELD attrname="DESCRICAO" fieldtype="string" WIDTH="40"/>  </FIELDS>  <PARAMS LCID="2057"/>  </METADATA>  <ROWDATA>  <ROW CODIGO="1" DESCRICAO="TESTE"/>  <ROW CODIGO="2" DESCRICAO="TESTANDO"/>  <ROW CODIGO="3" DESCRICAO="ARQUIVO XML"/>  </ROWDATA>  </DATAPACKET>

Se quiser, pode baixar neste endereço os fontes...

Compartilhar este post


Link para o post
Compartilhar em outros sites

outem como fazer isso:eu tenho esse xml:<raids> <!--<raid name="Testraid" file="testraid.xml" chance="50" interval="10" margin="0"/>--></raids>Como faço pra abrir ele em uma string tree? e add/remove valores, ou pelo menos pegar as tags e etc..

Compartilhar este post


Link para o post
Compartilhar em outros sites

<raids>

<raid name="AAA" file="testraid.xml" chance="50" interval="10" margin="0"/>

<raid name="ZZZZ" file="testraid.xml" chance="50" interval="10" margin="0"/>

</raids>

 

Vai sempre assim repetindo, o padrao e esses ai:

Name, file, chance, interval, margin ( se eh que isso e o padrao que voce dis)

 

queria que ficasse como esse aqui:(o programa nao e meu)

<?xml version="1.0"?><account pass="111" type="0" premDays="111"><characters><character name="aa" /></characters></account>
Imagem Postada

Compartilhar este post


Link para o post
Compartilhar em outros sites

Boa tarde amigo.

Tenho um sistema que ele cria alguns arquivos asssim

 

<?xml version="1.0" encoding="utf-8" ?>

- <LISTING CUSTOMERNUMBER="30" DATE="16/1/2008" HOUR="13:32:46" CURRENCYSYMBOL="R$" IDTYPE="listagem" UNIT="MM" AMBIENTS="3\0;2\0" QUANTITYINCREASE="N">

- <ABOUTPROMOB VERSION="5" REVISION="27" BUILD="4" SYSTEM="Todeschini" DISTRIBUTION="Studio" SERIALNUMBER="20648807" PRODUCTCODE="GGCFFKHOKJ" CUSTOMERNUMBER="6">

- <LIBRARIES>

<LIBRARY LINE="pias_tramontina" REVISION="04" VERSION="01/2008" />

<LIBRARY LINE="decore" REVISION="01" VERSION="01/07" />

<LIBRARY LINE="complementos" REVISION="04" VERSION="01/2008" />

<LIBRARY LINE="decore_todeschini" REVISION="04" VERSION="01/2008" />

<LIBRARY LINE="cozinhas" REVISION="04" VERSION="01/2008" />

<LIBRARY LINE="dormitorios" REVISION="04" VERSION="01/2008" />

<LIBRARY LINE="bibliotecas" REVISION="04" VERSION="01/2008" />

</LIBRARIES>

</ABOUTPROMOB>

- <CUSTOMERSDATA>

<DATA ID="codcliente" VALUE="" />

<DATA ID="rep_nomeempresa" VALUE="" />

<DATA ID="rep_cidadeempresa" VALUE="" />

<DATA ID="rep_ufempresa" VALUE="" />

<DATA ID="email" VALUE="" />

<DATA ID="fone" VALUE="3299-0730" />

<DATA ID="cep" VALUE="" />

<DATA ID="uf" VALUE="ES" />

<DATA ID="nomecliente" VALUE="Vera Lucia" />

<DATA ID="rep_telefoneempresa" VALUE="" />

<DATA ID="endentrega" VALUE="" />

<DATA ID="rep_emailempresa" VALUE="" />

<DATA ID="rep_cepenpresa" VALUE="" />

<DATA ID="rep_contatoempresa" VALUE="" />

<DATA ID="cpfcnpj" VALUE="" />

<DATA ID="endereco" VALUE="Ed. Royal Beach Aptº 1401" />

<DATA ID="rep_enderecoempresa" VALUE="" />

<DATA ID="cidade" VALUE="Vila Velha" />

<DATA ID="celular" VALUE="9963-8797" />

<DATA ID="bairro" VALUE="Itapoã" />

<DATA ID="observacoes" VALUE="" />

</CUSTOMERSDATA>

<TOTALPRICES />

- <AMBIENTS>

- <AMBIENT DESCRIPTION="Projeto - Ambiente 3D">

<TOTALPRICES />

- <CATEGORIES>

- <CATEGORY DESCRIPTION="Dormitórios">

<TOTALPRICES />

- <ITEMS>

- <ITEM DESCRIPTION="Arm. Duplo Baixo c/ 2 Prateleiras" OBSERVATIONS="" REFERENCE="26.265.981" UNIT="un" REPETITION="1" QUANTITY="2" WIDTH="849" HEIGHT="2291" DEPTH="580" TEXTDIMENSION="849 x 2291 x 580" COMPONENT="Y" FAMILY="Dormitórios" RULEQUANTITYINCREASE="N" RULEQUANTITYINCREASEPERCENT="0" IDPRICEPROVIDER="" IDPRICESOURCE="" UNIQUEID="120" UNIQUEPARENTID="-1">

- <REFERENCES>

<COMPLETE REFERENCE="26.265.981" />

</REFERENCES>

</ITEM>

- <ITEM DESCRIPTION="Arm. Estreito Menor Baixo c/ 5 Prateleiras" OBSERVATIONS="" REFERENCE="26.112.981" UNIT="un" REPETITION="1" QUANTITY="1" WIDTH="417" HEIGHT="2291" DEPTH="395" TEXTDIMENSION="417 x 2291 x 395" COMPONENT="Y" FAMILY="Dormitórios" RULEQUANTITYINCREASE="N" RULEQUANTITYINCREASEPERCENT="0" IDPRICEPROVIDER="" IDPRICESOURCE="" UNIQUEID="32" UNIQUEPARENTID="-1">

- <REFERENCES>

<COMPLETE REFERENCE="26.112.981" />

</REFERENCES>

</ITEM>

- <ITEM DESCRIPTION="Lateral Maior Dir. Baixa" OBSERVATIONS="" REFERENCE="29.785.981" UNIT="un" REPETITION="1" QUANTITY="2" WIDTH="18" HEIGHT="2291" DEPTH="580" TEXTDIMENSION="18 x 2291 x 580" COMPONENT="Y" FAMILY="Dormitórios" RULEQUANTITYINCREASE="N" RULEQUANTITYINCREASEPERCENT="0" IDPRICEPROVIDER="" IDPRICESOURCE="" UNIQUEID="111" UNIQUEPARENTID="-1">

- <REFERENCES>

<COMPLETE REFERENCE="29.785.981" />

</REFERENCES>

</ITEM>

- <ITEM DESCRIPTION="Lateral Maior Esq Baixa" OBSERVATIONS="" REFERENCE="29.786.981" UNIT="un" REPETITION="1" QUANTITY="2" WIDTH="18" HEIGHT="2291" DEPTH="580" TEXTDIMENSION="18 x 2291 x 580" COMPONENT="Y" FAMILY="Dormitórios" RULEQUANTITYINCREASE="N" RULEQUANTITYINCREASEPERCENT="0" IDPRICEPROVIDER="" IDPRICESOURCE="" UNIQUEID="110" UNIQUEPARENTID="-1">

- <REFERENCES>

<COMPLETE REFERENCE="29.786.981" />

</REFERENCES>

</ITEM>

- <ITEM DESCRIPTION="Lateral Menor Dir Baixa" OBSERVATIONS="" REFERENCE="26.796.981" UNIT="un" REPETITION="1" QUANTITY="1" WIDTH="18" HEIGHT="2291" DEPTH="395" TEXTDIMENSION="18 x 2291 x 395" COMPONENT="Y" FAMILY="Dormitórios" RULEQUANTITYINCREASE="N" RULEQUANTITYINCREASEPERCENT="0" IDPRICEPROVIDER="" IDPRICESOURCE="" UNIQUEID="27" UNIQUEPARENTID="-1">

- <REFERENCES>

<COMPLETE REFERENCE="26.796.981" />

</REFERENCES>

</ITEM>

- <ITEM DESCRIPTION="Lateral Menor Esq Baixa" OBSERVATIONS="" REFERENCE="26.795.981" UNIT="un" REPETITION="1" QUANTITY="1" WIDTH="18" HEIGHT="2291" DEPTH="395" TEXTDIMENSION="18 x 2291 x 395" COMPONENT="Y" FAMILY="Dormitórios" RULEQUANTITYINCREASE="N" RULEQUANTITYINCREASEPERCENT="0" IDPRICEPROVIDER="" IDPRICESOURCE="" UNIQUEID="26" UNIQUEPARENTID="-1">

- <REFERENCES>

<COMPLETE REFERENCE="26.795.981" />

</REFERENCES>

</ITEM>

- <ITEM DESCRIPTION="Porta Baixa Estreito MDF" OBSERVATIONS="" REFERENCE="27.321.71" UNIT="un" REPETITION="1" QUANTITY="5" WIDTH="429" HEIGHT="2210" DEPTH="18" TEXTDIMENSION="429 x 2210 x 18" COMPONENT="Y" FAMILY="Dormitórios" RULEQUANTITYINCREASE="N" RULEQUANTITYINCREASEPERCENT="0" IDPRICEPROVIDER="" IDPRICESOURCE="" UNIQUEID="31" UNIQUEPARENTID="-1">

- <REFERENCES>

<COMPLETE REFERENCE="27.321.71" />

</REFERENCES>

</ITEM>

</ITEMS>

</CATEGORY>

- <CATEGORY DESCRIPTION="Complementos">

<TOTALPRICES />

- <ITEMS>

- <ITEM DESCRIPTION="Puxador Acqua" OBSERVATIONS="" REFERENCE="89.575.16" UNIT="un" REPETITION="1" QUANTITY="5" WIDTH="30" HEIGHT="40" DEPTH="27" TEXTDIMENSION="30 x 40 x 27" COMPONENT="Y" FAMILY="Complementos" RULEQUANTITYINCREASE="N" RULEQUANTITYINCREASEPERCENT="0" IDPRICEPROVIDER="" IDPRICESOURCE="" UNIQUEID="28" UNIQUEPARENTID="-1">

- <REFERENCES>

<COMPLETE REFERENCE="89.575.16" />

</REFERENCES>

</ITEM>

</ITEMS>

</CATEGORY>

</CATEGORIES>

</AMBIENT>

- <AMBIENT DESCRIPTION="Cozinhas - Sugestao">

<TOTALPRICES />

<CATEGORIES />

</AMBIENT>

</AMBIENTS>

</LISTING>

 

Como montar em cima do seu para exportar ele para dentro de um banco de dados de pedidos em sql?

ou tenho este aqui que esta em txt

 

Loja =

Cliente = Vera Lucia

Endereco = Ed. Royal Beach Aptº 1401

Bairro = Itapoa

Cidade = Vila Velha

CEP =

Fone = 3299-0730

CPF =

EEntrega =

Obs =

1 2 26.265.981 Arm. Duplo Baixo c/ 2 Prateleiras 0,000,000,00Dormitorios

2 1 26.112.981 Arm. Estreito Menor Baixo c/ 5 Pr 0,000,000,00Dormitorios

3 2 29.785.981 Lateral Maior Dir. Baixa 0,000,000,00Dormitorios

4 2 29.786.981 Lateral Maior Esq Baixa 0,000,000,00Dormitorios

5 1 26.796.981 Lateral Menor Dir Baixa 0,000,000,00Dormitorios

6 1 26.795.981 Lateral Menor Esq Baixa 0,000,000,00Dormitorios

7 5 27.321.71 Porta Baixa Estreito MDF 0,000,000,00Dormitorios

8 5 89.575.16 Puxador Acqua 0,000,000,00Complementos

Total =

0,00

 

Aguardo retorno.

 

 

________________________________________________________________________________

_____________________

 

Precisei um dia de uma programa para abrir arquivos XML, procurei na internet somente achei programas que demoravam demais para abrir, então decidi desenvolver o meu programa para abrir os arquivos.

O que ele faz é criar tudo dinamicamente, ou seja, pode abrir quantos arquivos desejar, e permite que seja aplicado filtros sobre os registros. Não apliquei nenhuma "frescura" a mais pois não era necessáio, no caso segue os fontes se alguém quiser mexer e incrementar, não comentei os fontes, se tiver alguma dúvida, é só perguntar:

Imagem Postada

 

Arquivo DFM:

object frmPrincipal: TfrmPrincipal
	Left = 237
	Top = 103
	Width = 696
	Height = 480
	Caption = 'Abre XML'
	Color = clBtnFace
	Font.Charset = DEFAULT_CHARSET
	Font.Color = clWindowText
	Font.Height = -11
	Font.Name = 'MS Sans Serif'
	Font.Style = []
	OldCreateOrder = False
	PixelsPerInch = 96
	TextHeight = 13
	object Panel1: TPanel
	  Left = 0
	  Top = 0
	  Width = 688
	  Height = 41
	  Align = alTop
	  TabOrder = 0
	  object btnAbrir: TBitBtn
		Left = 8
		Top = 8
		Width = 75
		Height = 25
		Caption = 'Abrir'
		TabOrder = 0
		OnClick = btnAbrirClick
	  end
	  object Panel2: TPanel
		Left = 512
		Top = 1
		Width = 175
		Height = 39
		Align = alRight
		BevelOuter = bvNone
		TabOrder = 1
		object btnFecharAba: TBitBtn
		  Left = 19
		  Top = 7
		  Width = 75
		  Height = 25
		  Caption = 'Fechar Aba'
		  TabOrder = 0
		  OnClick = btnFecharAbaClick
		end
		object btnSair: TBitBtn
		  Left = 94
		  Top = 7
		  Width = 75
		  Height = 25
		  Caption = 'Sair'
		  TabOrder = 1
		  OnClick = btnSairClick
		end
	  end
	end
	object PageControl1: TPageControl
	  Left = 0
	  Top = 41
	  Width = 688
	  Height = 412
	  Align = alClient
	  TabOrder = 1
	end
	object OpenDialog: TOpenDialog
	  DefaultExt = '*.xml'
	  Filter = 'Arquivos XML|*.xml'
	  Left = 152
	  Top = 72
	end
  end

Arquivo .PAS

unit fPrincipal;
  
  interface
  
  uses
	Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
	Dialogs, DB, DBClient, Grids, DBGrids, StdCtrls, Buttons, ExtCtrls,
	ComCtrls;
  
  type
	TfrmPrincipal = class(TForm)
	  OpenDialog: TOpenDialog;
	  Panel1: TPanel;
	  btnAbrir: TBitBtn;
	  PageControl1: TPageControl;
	  Panel2: TPanel;
	  btnFecharAba: TBitBtn;
	  btnSair: TBitBtn;
	  procedure btnAbrirClick(Sender: TObject);
	  procedure btnFecharAbaClick(Sender: TObject);
	  procedure btnSairClick(Sender: TObject);
	private
	  { Private declarations }
	  procedure BotaoClick(Sender: TObject);
	public
	  { Public declarations }
	end;
  
  var
	frmPrincipal: TfrmPrincipal;
  
  implementation
  
  {$R *.dfm}
  
  procedure TfrmPrincipal.btnAbrirClick(Sender: TObject);
  var
	  cliente: TClientDataSet;
	  clienteSource: TDataSource;
	  grid: TDBGrid;
	  tabSheet: TTabSheet;
	  painel: TPanel;
	  edit: TEdit;
	  botao: TBitBtn;
	  lbl: TLabel;
  begin
  if OpenDialog.Execute then
	  begin
	  tabSheet:=TTabSheet.Create(PageControl1);
	  tabSheet.Parent:=PageControl1;
	  tabSheet.PageControl:=PageControl1;
	  tabSheet.Caption:=ExtractFileName(OpenDialog.FileName);
	  PageControl1.ActivePage:=tabSheet;
  
	  painel:=TPanel.Create(tabSheet);
	  painel.Parent:=tabSheet;
	  painel.Align:=alTop;
	  painel.Caption:='';
	  painel.Height:=30;
	  painel.BevelOuter:=bvNone;
  
	  edit:=TEdit.Create(painel);
	  edit.Parent:=painel;
	  edit.Text:='Filtro';
	  edit.CharCase:=ecUpperCase;
	  edit.Width:=225;
	  edit.Left:=10;
	  edit.Top:=5;
  
	  botao:=TBitBtn.Create(painel);
	  botao.Parent:=painel;
	  botao.Caption:='Filtrar';
	  botao.Width:=75;
	  botao.Left:=240;
	  botao.Top:=3;
	  botao.OnClick:=BotaoClick;
  
	  lbl:=TLabel.Create(painel);
	  lbl.Parent:=painel;
	  lbl.Caption:='0';
	  lbl.Left:=400;
	  lbl.Top:=10;
  
	  cliente:=TClientDataSet.Create(Self);
  
	  clienteSource:=TDataSource.Create(Self);
	  clienteSource.DataSet:=cliente;
  
	  grid:=TDBGrid.Create(tabSheet);
	  grid.Parent:=tabSheet;
	  grid.Align:=alClient;
	  grid.DataSource:=clienteSource;
  
	  cliente.FileName:=OpenDialog.FileName;
	  cliente.Open;
	  lbl.Caption:=FormatFloat('###,###,###',cliente.RecordCount) + ' registros.';
	  end;
  end;
  
  procedure TfrmPrincipal.BotaoClick(Sender: TObject);
  var
	  x, y, totalReg: integer;
	  aux: string;
  begin
  totalReg:=0;
  
  for x:=0 to PageControl1.ActivePage.ComponentCount - 1 do
	  if PageControl1.ActivePage.Components[x].ClassType = TPanel then
		  for y:=0 to (PageControl1.ActivePage.Components[x] as TPanel).ComponentCount - 1 do
			  if (PageControl1.ActivePage.Components[x] as TPanel).Components[y].ClassType = TEdit then
				  aux:=((PageControl1.ActivePage.Components[x] as TPanel).Components[y] as TEdit).Text;
  
  for x:=0 to PageControl1.ActivePage.ComponentCount - 1 do
	  begin
	  if PageControl1.ActivePage.Components[x].ClassType = TDBGrid then
		  begin
		  (PageControl1.ActivePage.Components[x] as TDBGrid).DataSource.DataSet.Filtered:=False;
		  if aux <> '' then
			  begin
			  (PageControl1.ActivePage.Components[x] as TDBGrid).DataSource.DataSet.Filter:=aux;
			  (PageControl1.ActivePage.Components[x] as TDBGrid).DataSource.DataSet.Filtered:=True;
			  end;
		  totalReg:=(PageControl1.ActivePage.Components[x] as TDBGrid).DataSource.DataSet.RecordCount;
		  end;
	  end;
  
  for x:=0 to PageControl1.ActivePage.ComponentCount - 1 do
	  if PageControl1.ActivePage.Components[x].ClassType = TPanel then
		  for y:=0 to (PageControl1.ActivePage.Components[x] as TPanel).ComponentCount - 1 do
			  if (PageControl1.ActivePage.Components[x] as TPanel).Components[y].ClassType = TLabel then
				   ((PageControl1.ActivePage.Components[x] as TPanel).Components[y] as  TLabel).Caption:=FormatFloat('###,###,###',totalReg) + ' registros.';
  end;
  
  procedure TfrmPrincipal.btnFecharAbaClick(Sender: TObject);
  begin
  if PageControl1.ActivePage <> nil then
	  PageControl1.ActivePage.Destroy;
  end;
  
  procedure TfrmPrincipal.btnSairClick(Sender: TObject);
  begin
  close;
  end;
  
  end.

E ainda...

Fiz ele somente abrindo este formato de XML:

<?xml version="1.0" standalone="yes"?>
  <DATAPACKET Version="2.0">
  <METADATA>
  <FIELDS>
  <FIELD attrname="CODIGO" fieldtype="r8"/>
  <FIELD attrname="DESCRICAO" fieldtype="string" WIDTH="40"/>
  </FIELDS>
  <PARAMS LCID="2057"/>
  </METADATA>
  <ROWDATA>
  <ROW CODIGO="1" DESCRICAO="TESTE"/>
  <ROW CODIGO="2" DESCRICAO="TESTANDO"/>
  <ROW CODIGO="3" DESCRICAO="ARQUIVO XML"/>
  </ROWDATA>
  </DATAPACKET>

 

Se quiser, pode baixar neste endereço os fontes...

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.