Hola a todos, necesito crear un archivo gpx con delphi, estoy usando el componente txmldocument, y tengo el siguiente codigo, pero cuando lo trato de abrir con un programa para archivos gpx me dice que mi archivo no es gpx.
Ojala que me puedan ayudar, llevo varios dias y no encuentro la forma:
Código Delphi
[-]
begin
XMLDoc.Active := False;
XMLDoc.XML.Text := '';
XMLDoc.Active := True;
iXml := XmlDoc.DOMDocument;
xmlNode := iXml.appendChild (iXml.createElement ('xml'));
iAttribute := iXml.createAttribute ('version');
iAttribute.nodeValue := '1.0';
xmlNode.attributes.setNamedItem (iAttribute);
gpxNode := xmlNode.appendChild(iXml.createElement ('gpx'));
iAttribute := iXml.createAttribute ('xmlns');
iAttribute.nodeValue := 'http.....';
gpxNode.attributes.setNamedItem (iAttribute);
iAttribute := iXml.createAttribute ('version');
iAttribute.nodeValue := '1.1';
gpxNode.attributes.setNamedItem (iAttribute);
iAttribute := iXml.createAttribute ('creator');
iAttribute.nodeValue := 'http.....';
gpxNode.attributes.setNamedItem (iAttribute);
iAttribute := iXml.createAttribute ('xmlns:xsi');
iAttribute.nodeValue := 'http.....';
gpxNode.attributes.setNamedItem (iAttribute);
iAttribute := iXml.createAttribute ('xsi:schemaLocation');
iAttribute.nodeValue := 'http.....';
gpxNode.attributes.setNamedItem (iAttribute);
mNode := xmlNode.appendChild(iXml.createElement ('metadata'));
bNode := mNode.appendChild(iXml.createElement ('bounds'));
iAttribute := iXml.createAttribute ('minlat');
iAttribute.nodeValue := '19.38975200';
bNode.attributes.setNamedItem (iAttribute);
iAttribute := iXml.createAttribute ('minlon');
iAttribute.nodeValue := '-99.17971000';
bNode.attributes.setNamedItem (iAttribute);
iAttribute := iXml.createAttribute ('maxlat');
iAttribute.nodeValue := '19.39671900';
bNode.attributes.setNamedItem (iAttribute);
iAttribute := iXml.createAttribute ('maxlon');
iAttribute.nodeValue := '-99.17543500';
bNode.attributes.setNamedItem (iAttribute);
trksegNode := xmlNode.appendChild(iXml.createElement ('wpt'));
iAttribute := iXml.createAttribute ('lat');
iAttribute.nodeValue := '19.39671900';
trksegNode.attributes.setNamedItem (iAttribute);
iAttribute := iXml.createAttribute ('lon');
iAttribute.nodeValue := '-99.17820800';
trksegNode.attributes.setNamedItem (iAttribute);
iAttribute := iXml.createAttribute ('name');
iAttribute.nodeValue := 'INDIANAPOLIS';
trksegNode.attributes.setNamedItem (iAttribute);
trksegNode := xmlNode.appendChild(iXml.createElement ('wpt'));
iAttribute := iXml.createAttribute ('lat');
iAttribute.nodeValue := '19.38975200';
trksegNode.attributes.setNamedItem (iAttribute);
iAttribute := iXml.createAttribute ('lon');
iAttribute.nodeValue := '-99.17543500';
trksegNode.attributes.setNamedItem (iAttribute);
iAttribute := iXml.createAttribute ('name');
iAttribute.nodeValue := 'SUPERAMA';
trksegNode.attributes.setNamedItem (iAttribute);
trksegNode := xmlNode.appendChild(iXml.createElement ('wpt'));
iAttribute := iXml.createAttribute ('lat');
iAttribute.nodeValue := '19.39119400';
trksegNode.attributes.setNamedItem (iAttribute);
iAttribute := iXml.createAttribute ('lon');
iAttribute.nodeValue := '-99.17971000';
trksegNode.attributes.setNamedItem (iAttribute);
iAttribute := iXml.createAttribute ('name');
iAttribute.nodeValue := 'CUMULUS1';
trksegNode.attributes.setNamedItem (iAttribute);
trkptNode := xmlNode.appendChild (iXml.createElement ('rte'));
trkNode := trkptNode.appendChild (iXml.createElement ('rtept'));
iAttribute := iXml.createAttribute ('lat');
iAttribute.nodeValue := '19.39671900';
trkNode.attributes.setNamedItem (iAttribute);
iAttribute := iXml.createAttribute ('lon');
iAttribute.nodeValue := '-99.17820800';
trkNode.attributes.setNamedItem (iAttribute);
iAttribute := iXml.createAttribute ('name');
iAttribute.nodeValue := 'INDIANAPOLIS';
trkNode.attributes.setNamedItem (iAttribute);
trkNode := trkptNode.appendChild (iXml.createElement ('rtept'));
iAttribute := iXml.createAttribute ('lat');
iAttribute.nodeValue := '19.38975200';
trkNode.attributes.setNamedItem (iAttribute);
iAttribute := iXml.createAttribute ('lon');
iAttribute.nodeValue := '-99.17543500';
trkNode.attributes.setNamedItem (iAttribute);
iAttribute := iXml.createAttribute ('name');
iAttribute.nodeValue := 'SUPERAMA';
trkNode.attributes.setNamedItem (iAttribute);
trkNode := trkptNode.appendChild (iXml.createElement ('rtept'));
iAttribute := iXml.createAttribute ('lat');
iAttribute.nodeValue := '19.39119400';
trkNode.attributes.setNamedItem (iAttribute);
iAttribute := iXml.createAttribute ('lon');
iAttribute.nodeValue := '-99.17971000';
trkNode.attributes.setNamedItem (iAttribute);
iAttribute := iXml.createAttribute ('name');
iAttribute.nodeValue := 'CUMULUS1';
trkNode.attributes.setNamedItem (iAttribute);
trkNode := trkptNode.appendChild (iXml.createElement ('rtept'));
iAttribute := iXml.createAttribute ('lat');
iAttribute.nodeValue := '19.39671900';
trkNode.attributes.setNamedItem (iAttribute);
iAttribute := iXml.createAttribute ('lon');
iAttribute.nodeValue := '-99.17820800';
trkNode.attributes.setNamedItem (iAttribute);
iAttribute := iXml.createAttribute ('name');
iAttribute.nodeValue := 'INDIANAPOLIS';
trkNode.attributes.setNamedItem (iAttribute);
Memo1.Lines.Text := FormatXMLData (XMLDoc.XML.Text);
XMLDoc.SaveToFile('C:\Users\j\Desktop\borrar\codigo2.gpx');
end;