I want to creat this xml file from a txt file...
i do this Code:
FXml := TNativeXml.CreateName('Root');
FXml.XmlFormat := xfReadable;
open the file
AssignFile(TFile,'user.txt');
Reset(TFile);
while not eof(TFile) do
begin
Readln(TFile,text);
r := Pos(' ',text);
t2 := Trim(Copy(text,1,Length(text)));
t1 := Trim(Copy(t2,0,r));
FXml.Root.NodeNew('row');
FXml.Root.NodeByName('row').WriteAttributeString('user',t2);
FXml.Root.NodeByName('row').WriteAttributeString('pin',t1);
end;
FXml.SaveToFile('new.xml');
FXml.free;
something i do wrong with nodebyname but what...
Thank you...
In case your text file contains more than one line, you are creating multiple nodes with the name "row". NodeByName will always return the first node with the given name.
You should store the result of NodeNew in a local variable of type TXmlNode and use that one to set the attributes.