Hi the Team,
I am creating an xml file from a geocoding application.
When reading the xml, I would like to know the number of polygons present by counting the number of "<Placemark>" nodes present (5 in our test.xml file).
I started with the "Show node names" example from the page
https://wiki.lazarus.freepascal.org/XML_Tutorial/fr but I get errors if I use my file.
I guess it doesn't work with my file because I still have other nodes under "Placemark".
var
Document: TXMLDocument;
i, j, K: Integer;
begin
ReadXMLFile(Document, 'test.kml');
Memo.Lines.Clear;
with Document.DocumentElement.ChildNodes do
//with Document.DocumentElement.ChildNodes.Item[1] do
begin
k := 0;
for i := 0 to (Count - 1) do
begin
Memo.Lines.Add(Item[i].NodeName + ' ' + Item[i].Attributes.Item[0].NodeValue);
for j := 0 to (Item[i].ChildNodes.Count - 1) do
begin
Memo.Lines.Add(Item[i].ChildNodes.Item[j].NodeName + ' ' + Item[i].ChildNodes.Item[j].FirstChild.NodeValue);
K := K+1;
end;
end;
end;
Showmessage(IntToStr(K));
Document.Free;
end;
The second step will be to insert the longitude and latitude values for each polygon of each node into a SQLite table (or 2 if necessary). The goal is to draw these polygons using "lazmapviewer" without having to reread the relevant XML.
Thanks for your help as I'm lost with the terminology "Node" and "ChildNode". English is not my native language.
Francois
You must renam the file test.txt in test.kml (Thanks)