Sample code for 30+ languages & platforms
Delphi ActiveX

Xml.UpdateAttrAt Example #2

Another Xml.UpdateAttrAt example...

Chilkat Delphi ActiveX Downloads

Delphi ActiveX
uses
    Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
    Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Chilkat_TLB;

...

procedure TForm1.Button1Click(Sender: TObject);
var
xml: TChilkatXml;
sbValue: TChilkatStringBuilder;
i: Integer;

begin
xml := TChilkatXml.Create(Self);
xml.Tag := 'abc';

sbValue := TChilkatStringBuilder.Create(Self);

i := 0;
while i < 10 do
  begin
    xml.I := i;
    sbValue.Clear();
    sbValue.AppendInt(i);
    xml.UpdateAttrAt('xyz|test[i]',1,'index',sbValue.GetAsString());
    i := i + 1;
  end;

Memo1.Lines.Add(xml.GetXml());

// Output is:

// 	<?xml version="1.0" encoding="utf-8" ?>
// 	<abc>
// 	    <xyz>
// 	        <test index="0" />
// 	        <test index="1" />
// 	        <test index="2" />
// 	        <test index="3" />
// 	        <test index="4" />
// 	        <test index="5" />
// 	        <test index="6" />
// 	        <test index="7" />
// 	        <test index="8" />
// 	        <test index="9" />
// 	    </xyz>
// 	</abc>
end;