I did not find a simple answer to your first question, but it follows:
What you can do to get an idea of the size of your XML is to stress your font.
I did a stress test in 5 minutes. It probably won’t suit you, because it has parameters other than your xml (that you did not send when asking the question), but it is necessary to explain my argument. Follow:
Var
XML : IXMLDOCUMENT;
RootNode, CurNode : IXMLNODE;
i : integer;
begin
XML := NewXMLDocument;
XML.Encoding := 'utf-8';
XML.Options := [doNodeAutoIndent]; // looks better in Editor ;)
RootNode := XML.AddChild('XML');
CurNode := RootNode.AddChild('Teste');
CurNode := CurNode.AddChild('Test22');
CurNode.Text := 'Texto Texto Test';
for I := 0 to 99 do
begin
CurNode.Attributes['Novo_Atributo' + IntToStr(i)] := 'Valor';
end;
XMl.SaveToFile('C:\teste.xml');
With this test I realized something interesting:
In the stretch
for I := 0 to 99 do
begin
CurNode.Attributes['Novo_Atributo' + IntToStr(i)] := 'Valor';
end;
I have the following disk size: 4,00 KB (4,096 bytes)
Changing the value of the bond from 99 to 199
for I := 0 to 199 do
begin
CurNode.Attributes['Novo_Atributo' + IntToStr(i)] := 'Valor';
end;
I have the following disk size: 8,00 KB (8,192 bytes)
From there, not reaching your 500kb becomes a simple 3 rule.
As for the second, from the moment your file is saved, as a rule nothing changes its size, don’t worry.
See if this site can help you.
– Samir Braga
@Samirbraga Help in part. The tip of the informed article explains how to check the size of a file. However, I need to check the size of a particular String which I will still save in xml file.
– wesley luan
To check if a file larger than 500kb obeys the rule, you first need to create this file...
– Filipe.Fonseca
To know what size the file will get, just count the size of the string in bytes, using Length. There is no need to physically create a copy on disk. In fact, if the file is going to be sent as an Nfe, for example, a local copy may well be stored in a database, and the XML string is sent directly to the SEFAZ (creating an intermediate file is totally unnecessary).
– Bacco
It is usually not recommended to ask two or more questions together when they do not interfere with each other. It’s hard for you to choose the best answer.
– EMBarbosa