GeoGet

Complete geocaching solutions

User Tools

Site Tools


user:navody:xml_parser

Differences

This shows you the differences between two versions of the page.


Previous revision
user:navody:xml_parser [2011/12/20 21:26] mikrom
Line 1: Line 1:
-====== XML parser ====== 
-GeoGet obsahuje XML parser již dlouho, ale od verze 2.6 je tento parser dostupný i všem skriptům. Jako parser je použita [[http://wiki.delphi-jedi.org/wiki/JCL_Help:JclSimpleXml.pas|volně dostupná knihovna]]. V uvedeném odkazu je k dispozici celý projekt, ale dokumentace je velmi strohá, a to je hodně nadnesené tvrzení. 
  
-Použití ve skriptu můžeme demonstrovat na jednoduchém příkladu: 
- 
-<code pascal> 
-uses simplexml; 
-... 
-procedure PluginStop; 
-var 
-  Xml: TJclSimpleXML; 
-  n: integer; 
-  s: string; 
-  ele: TJclSimpleXMLElem; 
-begin 
-  Xml := TJclSimpleXML.Create; 
-  try 
-    xml.loadfromfile('test.gpx', seAuto, 0); 
-    showmessage(XML.Root.Name); 
-    for n := 0 to XML.Root.Items.count - 1 do 
-    begin 
-      ele := XML.Root.Items[n];  
-      if ele.name = 'wpt' then 
-      begin 
-        s := 'X:' + ele.properties.ItemNamed['lat'].Value; 
-        s := s + ' Y:' + ele.properties.ItemNamed['lon'].Value; 
-        showmessage(s); 
-        ele := ele.items.Itemnamed['cache']; 
-        if assigned(ele) then 
-        begin 
-          ele := ele.items.Itemnamed['long_description']; 
-          if assigned(ele) then 
-            begin 
-              s := ele.value; 
-              Stringtofile(s, 'test.txt'); 
-            end; 
-          end; 
-      end; 
-    end; 
-  finally 
-    xml.free; 
-  end; 
-end; 
-</code> 
- 
- 
-{{tag>upravy}} 
user/navody/xml_parser.txt · Last modified: 2015/09/21 00:00 (external edit)