This is my xml file:
<?xml version="1.0" encoding="utf-8"?>
<UsersF Ver="1.1">
<row User="1" Pin="2y44ic" ExtPag="full"/>
<row User="2" pin="tfde88" ExtPag="e45" />
<row User="3" Pin="9gr444466gg" Level="nov" GamePag="3" />
</UsersF>
And this is the code that I get access and put a string-grid... I use the nextgrid ...
procedure showXmlToString;
Count:= 0;
Conf.nxtgrd.AddRow(71);
Conf.nxtgrd.BeginUpdate;
with FXml.Root do
for i := 0 to NodeCount - 1 do
begin
if Nodes[i].Name <> 'Ver' then
begin
Conf.nxtgrd.Cell[0,count].AsString := Nodes[i].Nodes[1].Value;
Conf.nxtgrd.Cell[1,count].AsString := Nodes[i].Nodes[2].Value;
Conf.nxtgrd.Cell[2,count].AsString := Nodes[i].Nodes[3].Value;
Conf.nxtgrd.Cell[3,count].AsString := Nodes[i].Nodes[4].Value;
count := count + 1;
end;
end;
When it come to line that the node not exits I get the error.
To accessing the attributes you can use
TXmlNode.AttributeCount
to iterate numbers of attributes available. If the main point of this code is to obtain the attributes, you can access them usingTXmlNode.Containers
.Let say you want to get all the attributes name & value, you can using following iteration:
In this example
Log
procedure will display the string to the screen. As the result the output will be like this:I hope this help you.