read xml doc

21 kali dilihat
Langsung ke pesan pertama yang belum dibaca

Ioan Ghip

belum dibaca,
15 Mei 2006 16.44.1215/05/06
kepada
Hi all,
I need a small example on how to read all the "lat" and "lon" values in
a xml document like this one:

<?xml version="1.0"?>
<gpx version="1.0" creator="http://www.gnuite.com/cgi-bin/gpx.cgi"
xmlns="http://www.topografix.com/GPX/1/0">
<trk>
<trkseg>
<trkpt lat="45.5238" lon="-122.67501">
<desc>Head east from Northwest Couch Street. Go 0.2
miles.</desc></trkpt>
<trkpt lat="45.52382" lon="-122.67441"/>
<trkpt lat="45.52383" lon="-122.67339"/>
</trkseg>
</trk>
</gpx>

thanks
-ioan

Mikael Eriksson

belum dibaca,
16 Mei 2006 03.01.5916/05/06
kepada
var
xd: IXMLDocument;
nl: IXMLNodeList;
I: Integer;
begin
xd := LoadXMLData(
'<?xml version="1.0"?>'+
'<gpx version="1.0" creator="http://www.gnuite.com/cgi-bin/gpx.cgi"
xmlns="http://www.topografix.com/GPX/1/0">'+
' <trk>'+
' <trkseg>'+
' <trkpt lat="45.5238" lon="-122.67501">'+
' <desc>Head east from Northwest Couch Street. Go 0.2
miles.</desc></trkpt>'+
' <trkpt lat="45.52382" lon="-122.67441"/>'+
' <trkpt lat="45.52383" lon="-122.67339"/>'+
' </trkseg>'+
' </trk>'+
'</gpx>'
);

nl :=
xd.ChildNodes['gpx'].ChildNodes['trk'].ChildNodes['trkseg'].ChildNodes;
for I := 0 to nl.Count - 1 do
begin
Memo1.Lines.Add(nl[I].Attributes['lat']);
Memo1.Lines.Add(nl[I].Attributes['lon']);
end;
end;

Ioan Ghip

belum dibaca,
16 Mei 2006 13.10.1416/05/06
kepadaMikael Eriksson
Mikael Eriksson wrote:
[...]

thanks Mikael,
-i

Balas ke semua
Balas ke penulis
Teruskan
0 pesan baru