Arquivo XML - Como alterar o attributo em Run Time ?
Olá boa tarde!
Tenho um arquivo XML e preciso alterar o tamanho do attribu Path de Tamanho 80 para 100.
Como poso fgazer isto em Run Time?
A quem puder ajudar desde já meus agradecimentos.
ANT.CARLOS/SP
Exemplo abaixo.
=============================
<?xml version=1.0 standalone=yes ?>
- <DATAPACKET Version=2.0>
- <METADATA>
- <FIELDS>
<FIELD attrname=Codemp fieldtype=i4 />
<FIELD attrname=Numnota fieldtype=i4 />
<FIELD attrname=Path fieldtype=string WIDTH=80 />
<FIELD attrname=Chave fieldtype=string WIDTH=50 />
<FIELD attrname=Dtemissao fieldtype=date />
</FIELDS>
<PARAMS />
</METADATA>
<ROWDATA />
</DATAPACKET>
=============================
Tenho um arquivo XML e preciso alterar o tamanho do attribu Path de Tamanho 80 para 100.
Como poso fgazer isto em Run Time?
A quem puder ajudar desde já meus agradecimentos.
ANT.CARLOS/SP
Exemplo abaixo.
=============================
<?xml version=1.0 standalone=yes ?>
- <DATAPACKET Version=2.0>
- <METADATA>
- <FIELDS>
<FIELD attrname=Codemp fieldtype=i4 />
<FIELD attrname=Numnota fieldtype=i4 />
<FIELD attrname=Path fieldtype=string WIDTH=80 />
<FIELD attrname=Chave fieldtype=string WIDTH=50 />
<FIELD attrname=Dtemissao fieldtype=date />
</FIELDS>
<PARAMS />
</METADATA>
<ROWDATA />
</DATAPACKET>
=============================
Antonio Jesus
Curtidas 0
Respostas
Marco Salles
03/02/2012
Olá Antonio , me parece um XML no formato DATAPACKET . Porém não esta bem formatado
Acho que deve ser na hora de copiar e colar
O correto seria a meu ver isto
<?xml version=1.0 standalone=yes ?>
<DATAPACKET Version=2.0>
<METADATA>
<FIELDS>
<FIELD attrname=Codemp fieldtype=i4/>
<FIELD attrname=Numnota fieldtype=i4/>
<FIELD attrname=Path fieldtype=string WIDTH=80/>
<FIELD attrname=Chave fieldtype=string WIDTH=50/>
<FIELD attrname=Dtemissao fieldtype=date/>
</FIELDS>
<PARAMS />
</METADATA>
<ROWDATA />
</DATAPACKET>
Olhe as Aspas nos Atributos ..enfim , utilizando o método abaixo neste XML DataPAcker
var
cds:TClientDataSet;
begin
cds:=TClientDataSet.Create(nil);
try
with cds do
begin
LoadFromFile(C:\xxxxxxxxPodeApagar\podeApagar.xml);
EmptyDataSet; // opcional
FieldDefs.Delete(cds.FieldDefs.IndexOf(Path));
FieldDefs.Add(Path,ftString,100);
close;
CreateDataSet;
SaveToFile(C:\xxxxxxxxPodeApagar\podeApagar3.xml,dfXMLUTF8);
//Padrão dfXMLUTF8 opcional ... Pode ser utilizado outros
end;
finally
cds.Free;
Obten-se como saida
<?xml version=1.0 encoding=UTF-8 standalone=yes?>
<DATAPACKET Version=2.0>
<METADATA>
<FIELDS>
<FIELD attrname=Codemp fieldtype=i4/>
<FIELD attrname=Numnota fieldtype=i4/>
<FIELD attrname=Chave fieldtype=string WIDTH=50/>
<FIELD attrname=Dtemissao fieldtype=date/>
<FIELD attrname=Path fieldtype=string WIDTH=100/>
</FIELDS>
<PARAMS/>
</METADATA>
<ROWDATA>
</ROWDATA>
</DATAPACKET>
Onde o WIDTH=100 agora esta alterado para 100
Espero ter sido útil
Acho que deve ser na hora de copiar e colar
O correto seria a meu ver isto
<?xml version=1.0 standalone=yes ?>
<DATAPACKET Version=2.0>
<METADATA>
<FIELDS>
<FIELD attrname=Codemp fieldtype=i4/>
<FIELD attrname=Numnota fieldtype=i4/>
<FIELD attrname=Path fieldtype=string WIDTH=80/>
<FIELD attrname=Chave fieldtype=string WIDTH=50/>
<FIELD attrname=Dtemissao fieldtype=date/>
</FIELDS>
<PARAMS />
</METADATA>
<ROWDATA />
</DATAPACKET>
Olhe as Aspas nos Atributos ..enfim , utilizando o método abaixo neste XML DataPAcker
var
cds:TClientDataSet;
begin
cds:=TClientDataSet.Create(nil);
try
with cds do
begin
LoadFromFile(C:\xxxxxxxxPodeApagar\podeApagar.xml);
EmptyDataSet; // opcional
FieldDefs.Delete(cds.FieldDefs.IndexOf(Path));
FieldDefs.Add(Path,ftString,100);
close;
CreateDataSet;
SaveToFile(C:\xxxxxxxxPodeApagar\podeApagar3.xml,dfXMLUTF8);
//Padrão dfXMLUTF8 opcional ... Pode ser utilizado outros
end;
finally
cds.Free;
Obten-se como saida
<?xml version=1.0 encoding=UTF-8 standalone=yes?>
<DATAPACKET Version=2.0>
<METADATA>
<FIELDS>
<FIELD attrname=Codemp fieldtype=i4/>
<FIELD attrname=Numnota fieldtype=i4/>
<FIELD attrname=Chave fieldtype=string WIDTH=50/>
<FIELD attrname=Dtemissao fieldtype=date/>
<FIELD attrname=Path fieldtype=string WIDTH=100/>
</FIELDS>
<PARAMS/>
</METADATA>
<ROWDATA>
</ROWDATA>
</DATAPACKET>
Onde o WIDTH=100 agora esta alterado para 100
Espero ter sido útil
GOSTEI 0
Marco Salles
03/02/2012
Olá Antonio , me parece um XML no formato DATAPACKET . Porém não esta bem formatado
Acho que deve ser na hora de copiar e colar
O correto seria a meu ver isto
<?xml version=1.0 standalone=yes ?>
<DATAPACKET Version=2.0>
<METADATA>
<FIELDS>
<FIELD attrname=Codemp fieldtype=i4/>
<FIELD attrname=Numnota fieldtype=i4/>
<FIELD attrname=Path fieldtype=string WIDTH=80/>
<FIELD attrname=Chave fieldtype=string WIDTH=50/>
<FIELD attrname=Dtemissao fieldtype=date/>
</FIELDS>
<PARAMS />
</METADATA>
<ROWDATA />
</DATAPACKET>
Olhe as Aspas nos Atributos ..enfim , utilizando o método abaixo neste XML DataPAcker
var
cds:TClientDataSet;
begin
cds:=TClientDataSet.Create(nil);
try
with cds do
begin
LoadFromFile(C:\xxxxxxxxPodeApagar\podeApagar.xml);
EmptyDataSet; // opcional
FieldDefs.Delete(cds.FieldDefs.IndexOf(Path));
FieldDefs.Add(Path,ftString,100);
close;
CreateDataSet;
SaveToFile(C:\xxxxxxxxPodeApagar\podeApagar3.xml,dfXMLUTF8);
//Padrão dfXMLUTF8 opcional ... Pode ser utilizado outros
end;
finally
cds.Free;
Obten-se como saida
<?xml version=1.0 standalone=yes ?>
<DATAPACKET Version=2.0>
<METADATA>
<FIELDS>
<FIELD attrname=Codemp fieldtype=i4/>
<FIELD attrname=Numnota fieldtype=i4/>
<FIELD attrname=Chave fieldtype=string WIDTH=50/>
<FIELD attrname=Dtemissao fieldtype=date/>
<FIELD attrname=Path fieldtype=string WIDTH=100/>
</FIELDS>
<PARAMS />
</METADATA>
<ROWDATA />
</DATAPACKET>
Onde o WIDTH=100 agora esta alterado para 100
Espero ter sido útil
Acho que deve ser na hora de copiar e colar
O correto seria a meu ver isto
<?xml version=1.0 standalone=yes ?>
<DATAPACKET Version=2.0>
<METADATA>
<FIELDS>
<FIELD attrname=Codemp fieldtype=i4/>
<FIELD attrname=Numnota fieldtype=i4/>
<FIELD attrname=Path fieldtype=string WIDTH=80/>
<FIELD attrname=Chave fieldtype=string WIDTH=50/>
<FIELD attrname=Dtemissao fieldtype=date/>
</FIELDS>
<PARAMS />
</METADATA>
<ROWDATA />
</DATAPACKET>
Olhe as Aspas nos Atributos ..enfim , utilizando o método abaixo neste XML DataPAcker
var
cds:TClientDataSet;
begin
cds:=TClientDataSet.Create(nil);
try
with cds do
begin
LoadFromFile(C:\xxxxxxxxPodeApagar\podeApagar.xml);
EmptyDataSet; // opcional
FieldDefs.Delete(cds.FieldDefs.IndexOf(Path));
FieldDefs.Add(Path,ftString,100);
close;
CreateDataSet;
SaveToFile(C:\xxxxxxxxPodeApagar\podeApagar3.xml,dfXMLUTF8);
//Padrão dfXMLUTF8 opcional ... Pode ser utilizado outros
end;
finally
cds.Free;
Obten-se como saida
<?xml version=1.0 standalone=yes ?>
<DATAPACKET Version=2.0>
<METADATA>
<FIELDS>
<FIELD attrname=Codemp fieldtype=i4/>
<FIELD attrname=Numnota fieldtype=i4/>
<FIELD attrname=Chave fieldtype=string WIDTH=50/>
<FIELD attrname=Dtemissao fieldtype=date/>
<FIELD attrname=Path fieldtype=string WIDTH=100/>
</FIELDS>
<PARAMS />
</METADATA>
<ROWDATA />
</DATAPACKET>
Onde o WIDTH=100 agora esta alterado para 100
Espero ter sido útil
Caramba a formatação do Site some com as ASPAS nos Atributos
Meu Deus vamos chamar um Programador para fazer melhoras no nosso Site da DevMédia
GOSTEI 0