Hallo,

Ik wil in een gpx file gaan lezen vanaf een bepaalde plaats(vb waar telkens <wpt begint) , daar maak ik dan een file van fread($fopen, 3800); met deze grootte, daarna moet er terug gezocht worden naar <wpt om terug een file van 3800 van te maken.

Ziet iemand dit zitten om hier een klein voorbeeld van te geven ?
Als je wil kan ik altijd de gpx aan iemand laten geworden.(blijkbaar kan ik hier geen file doorsturen)

Met dank op voorhand
Ozzie het gevraagde


<?xml version="1.0" encoding="utf-8"?>
<gpx xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
version="1.0" creator="GSAK"
xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd http://www.groundspeak:.com/cache/1/0/1 http://www.groundspeak:.com/cache/1/0/1/cache.xsd"
xmlns="http://www.topografix.com/GPX/1/0">
 <desc>Geocache file generated by GSAK</desc>
 <author>GSAK</author>
 <email>[email protected]</email>
 <time>2023-02-17T14:03:48Z</time>
 <keywords>cache, geocache, groundspeak:</keywords>
 <bounds minlat="50.53355" minlon="4.0968" maxlat="50.559167" maxlon="4.130833"/>
 <wpt lat="50.558333" lon="4.101667">
  <time>2022-12-24T08:00:00Z</time>
  <name>GCA02MB</name>
  <desc>26. Il y a de l'illusion dans l'air by Jc et Fr (2/2)</desc>
  <url>http://coord.info/GCA02MB</url>
  <urlname>26. Il y a de l'illusion dans l'air by Jc et Fr</urlname>
  <sym>Geocache</sym>
  <type>Geocache|Unknown Cache</type>
  <groundspeak:cache id="8826643" available="True" archived="False" xmlns:groundspeak:="http://www.groundspeak:.com/cache/1/0/1">
   <groundspeak:name>26. Il y a de l'illusion dans l'air</groundspeak:name>
   <groundspeak:placed_by>Jc et Fr</groundspeak:placed_by>
   <groundspeak:owner id="13158440">Jc et Fr</groundspeak:owner>
   <groundspeak:type>Unknown Cache</groundspeak:type>
   <groundspeak:container>Micro</groundspeak:container>
   <groundspeak:attributes>
     <groundspeak:attribute id="6" inc="1">Recommended for kids</groundspeak:attribute>
     <groundspeak:attribute id="9" inc="1">Significant hike</groundspeak:attribute>
     <groundspeak:attribute id="13" inc="1">Available at all times</groundspeak:attribute>
     <groundspeak:attribute id="15" inc="1">Available during winter</groundspeak:attribute>
     <groundspeak:attribute id="32" inc="1">Bicycles</groundspeak:attribute>
     <groundspeak:attribute id="41" inc="1">Stroller accessible</groundspeak:attribute>
     <groundspeak:attribute id="63" inc="1">Tourist Friendly</groundspeak:attribute>
   </groundspeak:attributes>
   <groundspeak:difficulty>2</groundspeak:difficulty>
   <groundspeak:terrain>2</groundspeak:terrain>
   <groundspeak:country>Belgium</groundspeak:country>
   <groundspeak:state>Hainaut</groundspeak:state>
   <groundspeak:short_description html="False"> </groundspeak:short_description>
Zo te zien mis je nog een deel.
Voor het gemak heb ik dit tussen code-tags geplaatst. Voortaan graag zelf doen aub.
ja enkel het einde, de vraag van ozzie was max 25 regels
Ongeveer....
We willen wel wat volledigs maar beknopts zien. Dus als er bij wijze van spreken 53 items in staan, gelieve dit te beperken tot 2 stuks ofzo.
- Ariën - op 19/02/2023 08:57:47

Ikzelf gebruik geloof zo een constructie:

$string= file_get_content("bla.xml") waarna ik $xml=simplexml_load_string($string) gebruik.

Als je nu een beknopte sample op Pastebin plaatst met een paar geocache items. Met een half deel kunnen we niet veel als we niet weten welke tags (nodes) er gebruikt worden.


Parse error: syntax error, unexpected token ":", expecting "," or ";" in C:\xampp\htdocs\geo_db_gpx_gsak\test.php on line 11


<?php
header ('Content-type: text/html; charset=utf8mb4');
$string=file_get_content("c:/geo_db/test.gpx");
$xml=simplexml_load_file($string) or die("Error: Cannot create object");
//var_dump($xml->wpt[0]);
echo $xml->wpt[0]['lat'] . "<br>";
echo $xml->wpt[0]['lon'] . "<br>";
echo $xml->wpt[0]->name . "<br>";
echo $xml->wpt[0]->desc . "<br>";
echo $xml->wpt[0]->type . "<br>";
echo $xml->wpt[0]->groundspeak:container . "<br>";
echo $xml->wpt[0]->groundspeak:difficulty . "<br>";
echo $xml->wpt[0]->groundspeak:terrain . "<br>";
echo $xml->wpt[0]->groundspeak:country . "<br>";
echo $xml->wpt[0]->groundspeak:state . "<br>";
?>


Blijkbaar is het met dit ook niet te eenvoudig om een gpx uit te lezen ...



[size=xsmall]Toevoeging op 19/02/2023 09:50:40:[/size]

Ariën hier zijn 2 stuks

<?xml version="1.0" encoding="utf-8"?>
<gpx xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
version="1.0" creator="GSAK"
xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd http://www.groundspeak:.com/cache/1/0/1 http://www.groundspeak:.com/cache/1/0/1/cache.xsd"
xmlns="http://www.topografix.com/GPX/1/0">
 <desc>Geocache file generated by GSAK</desc>
 <author>GSAK</author>
 <email>[email protected]</email>
 <time>2023-02-17T14:03:48Z</time>
 <keywords>cache, geocache, groundspeak:</keywords>
 <bounds minlat="50.53355" minlon="4.0968" maxlat="50.559167" maxlon="4.130833"/>
 <wpt lat="50.558333" lon="4.101667">
  <time>2022-12-24T08:00:00Z</time>
  <name>GCA02MB</name>
  <desc>26. Il y a de l'illusion dans l'air by Jc et Fr (2/2)</desc>
  <url>http://coord.info/GCA02MB</url>
  <urlname>26. Il y a de l'illusion dans l'air by Jc et Fr</urlname>
  <sym>Geocache</sym>
  <type>Geocache|Unknown Cache</type>
  <groundspeak:cache id="8826643" available="True" archived="False" xmlns:groundspeak:="http://www.groundspeak:.com/cache/1/0/1">
   <groundspeak:name>26. Il y a de l'illusion dans l'air</groundspeak:name>
   <groundspeak:placed_by>Jc et Fr</groundspeak:placed_by>
   <groundspeak:owner id="13158440">Jc et Fr</groundspeak:owner>
   <groundspeak:type>Unknown Cache</groundspeak:type>
   <groundspeak:container>Micro</groundspeak:container>
   <groundspeak:attributes>
     <groundspeak:attribute id="6" inc="1">Recommended for kids</groundspeak:attribute>
     <groundspeak:attribute id="9" inc="1">Significant hike</groundspeak:attribute>
     <groundspeak:attribute id="13" inc="1">Available at all times</groundspeak:attribute>
     <groundspeak:attribute id="15" inc="1">Available during winter</groundspeak:attribute>
     <groundspeak:attribute id="32" inc="1">Bicycles</groundspeak:attribute>
     <groundspeak:attribute id="41" inc="1">Stroller accessible</groundspeak:attribute>
     <groundspeak:attribute id="63" inc="1">Tourist Friendly</groundspeak:attribute>
   </groundspeak:attributes>
   <groundspeak:difficulty>2</groundspeak:difficulty>
   <groundspeak:terrain>2</groundspeak:terrain>
   <groundspeak:country>Belgium</groundspeak:country>
   <groundspeak:state>Hainaut</groundspeak:state>
   <groundspeak:short_description html="False"> </groundspeak:short_description>
   <groundspeak:long_description html="True">&lt;p style="text-align:center;"&gt;&lt;img src="https://img.geocaching.com:443/8e0188ec-8fe0-4a56-a109-6d2326125bcf.png" /&gt;&lt;/p&gt;

&lt;p&gt;Cette cache fait partie d'une série de 41 mystères qui vous emmèneront faire une balade de &lt;span style="color:#2ecc71;"&gt;+/- 8 kms à vol d'oiseau.&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;Elle est réalisable à pieds, à vélo ou avec des poussettes, moitié sur routes moyennement fréquentées (sauf un petit tronçon plus dangereux) et moitié sur chemins de terre parfois assez caillouteux mais sans grandes difficultés au niveau des dénivelés.&lt;/p&gt;

&lt;p&gt;&lt;span style="color:#e74c3c;"&gt;N’oubliez pas votre canne à pêche, vous en aurez besoin à 8 reprises.&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;Vous pouvez commencer la balade où vous voulez puisqu'il n'y a pas de bonus.&lt;/p&gt;

&lt;p&gt;La difficulté indiquée en haut de la page est celle que vous rencontrerez sur place.&lt;/p&gt;

&lt;p&gt;La difficulté de la résolution de cette cache-ci est du niveau 2.&lt;/p&gt;

&lt;p&gt;Au niveau du décodage, vous devrez faire des puzzles de maximum 70 pièces au bout desquels vous devrez être attentifs aux messages qui apparaitront car ils vous donneront des indications sur la suite des réjouissances. &lt;img alt="wink" height="23" src="https://cdn.ckeditor.com/4.13.0/full-all/plugins/smiley/images/wink_smile.png" title="wink" width="23" /&gt;&lt;/p&gt;

&lt;p&gt;Soit une question vous sera posée et la réponse devra être entrée dans un checker certitude. &lt;span style="color:#e74c3c;"&gt;Si elle comprend plusieurs parties, les mots devront être écrits en majuscules, sans accents, les nombres en chiffres et toutes les parties devront être collées ensemble.&lt;/span&gt; Une bonne réponse entrainera la réception des coordonnées nord ou est de la boite finale. Conservez-les.&lt;/p&gt;

&lt;p&gt;Soit vous devrez encore découvrir les coordonnées. Comme elles seront en deux parties (nord et est), il faudra aussi les conserver pour les entrer ensemble dans le checker.&lt;/p&gt;

&lt;p&gt;Bon amusement !&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Pour réaliser le premier puzzle, cliquez sur le lien suivant :&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;.&lt;/p&gt;

&lt;p style="text-align:center;"&gt;&lt;a href="https://www.jigidi.com/solve/3aojqm5h/26-a/"&gt;&lt;img alt src="https://img.geocaching.com/cache/large/5ab61dea-f76f-473b-b6a9-9aefd73653a8.png?rnd=0.3294783" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;.&lt;/p&gt;

&lt;p style="text-align:center;"&gt;&lt;a href="https://www.certitudes.org/certitude?wp=W1A02MB"&gt;&lt;img src="https://www.certitudes.org/logo?wp=W1A02MB" title="Cliquer pour voir la liste des utilisateurs ayant résolu l'énigme" /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span style="font-family:Comic Sans MS;"&gt;Vous pouvez valider votre solution d'énigme avec &lt;a href="https://www.certitudes.org/certitude?wp=W1A02MB"&gt;certitude&lt;/a&gt;.&lt;/span&gt;&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Pour réaliser le second puzzle, cliquez sur le lien suivant :&lt;/p&gt;

&lt;p&gt;.&lt;/p&gt;

&lt;p style="text-align:center;"&gt;&lt;a href="https://www.jigidi.com/solve/gr8k5yxw/26-b/"&gt;&lt;img alt src="https://img.geocaching.com/cache/large/5ab61dea-f76f-473b-b6a9-9aefd73653a8.png?rnd=0.3294783" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;.&lt;/p&gt;

&lt;p style="text-align:center;"&gt;&lt;a href="https://www.certitudes.org/certitude?wp=W2A02MB"&gt;&lt;img src="https://www.certitudes.org/logo?wp=W2A02MB" title="Cliquer pour voir la liste des utilisateurs ayant résolu l'énigme" /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span style="font-family:Comic Sans MS;"&gt;Vous pouvez valider votre solution d'énigme avec &lt;a href="https://www.certitudes.org/certitude?wp=W2A02MB"&gt;certitude&lt;/a&gt;.&lt;/span&gt;&lt;/p&gt;</groundspeak:long_description>
    <groundspeak:encoded_hints></groundspeak:encoded_hints>
   <groundspeak:logs>
  </groundspeak:logs>
   <groundspeak:travelbugs>
   </groundspeak:travelbugs>
</groundspeak:cache>
</wpt>
 <wpt lat="50.559167" lon="4.1025">
  <time>2022-12-24T08:00:00Z</time>
  <name>GCA02MK</name>
  <desc>28. Il y a de l'illusion dans l'air by Jc et Fr (2/2)</desc>
  <url>http://coord.info/GCA02MK</url>
  <urlname>28. Il y a de l'illusion dans l'air by Jc et Fr</urlname>
  <sym>Geocache</sym>
  <type>Geocache|Unknown Cache</type>
  <groundspeak:cache id="8826651" available="True" archived="False" xmlns:groundspeak:="http://www.groundspeak:.com/cache/1/0/1">
   <groundspeak:name>28. Il y a de l'illusion dans l'air</groundspeak:name>
   <groundspeak:placed_by>Jc et Fr</groundspeak:placed_by>
   <groundspeak:owner id="13158440">Jc et Fr</groundspeak:owner>
   <groundspeak:type>Unknown Cache</groundspeak:type>
   <groundspeak:container>Micro</groundspeak:container>
   <groundspeak:attributes>
     <groundspeak:attribute id="6" inc="1">Recommended for kids</groundspeak:attribute>
     <groundspeak:attribute id="9" inc="1">Significant hike</groundspeak:attribute>
     <groundspeak:attribute id="13" inc="1">Available at all times</groundspeak:attribute>
     <groundspeak:attribute id="15" inc="1">Available during winter</groundspeak:attribute>
     <groundspeak:attribute id="32" inc="1">Bicycles</groundspeak:attribute>
     <groundspeak:attribute id="41" inc="1">Stroller accessible</groundspeak:attribute>
     <groundspeak:attribute id="56" inc="1">Medium hike (1km-10km)</groundspeak:attribute>
     <groundspeak:attribute id="63" inc="1">Tourist Friendly</groundspeak:attribute>
   </groundspeak:attributes>
   <groundspeak:difficulty>2</groundspeak:difficulty>
   <groundspeak:terrain>2</groundspeak:terrain>
   <groundspeak:country>Belgium</groundspeak:country>
   <groundspeak:state>Hainaut</groundspeak:state>
   <groundspeak:short_description html="False"> </groundspeak:short_description>
   <groundspeak:long_description html="True">&lt;p style="text-align:center;"&gt;&lt;img src="https://img.geocaching.com:443/ce583082-fba5-4f1c-92fd-a8d0f2874ea1.png" /&gt;&lt;/p&gt;

&lt;p&gt;Cette cache fait partie d'une série de 41 mystères qui vous emmèneront faire une balade de &lt;span style="color:#2ecc71;"&gt;+/- 8 kms à vol d'oiseau.&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;Elle est réalisable à pieds, à vélo ou avec des poussettes, moitié sur routes moyennement fréquentées (sauf un petit tronçon plus dangereux) et moitié sur chemins de terre parfois assez caillouteux mais sans grandes difficultés au niveau des dénivelés.&lt;/p&gt;

&lt;p&gt;&lt;span style="color:#e74c3c;"&gt;N’oubliez pas votre canne à pêche, vous en aurez besoin à 8 reprises.&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;Vous pouvez commencer la balade où vous voulez puisqu'il n'y a pas de bonus.&lt;/p&gt;

&lt;p&gt;La difficulté indiquée en haut de la page est celle que vous rencontrerez sur place.&lt;/p&gt;

&lt;p&gt;La difficulté de la résolution de cette cache-ci est du niveau 2.&lt;/p&gt;

&lt;p&gt;Au niveau du décodage, vous devrez faire des puzzles de maximum 70 pièces au bout desquels vous devrez être attentifs aux messages qui apparaitront car ils vous donneront des indications sur la suite des réjouissances. &lt;img alt="wink" height="23" src="https://cdn.ckeditor.com/4.13.0/full-all/plugins/smiley/images/wink_smile.png" title="wink" width="23" /&gt;&lt;/p&gt;

&lt;p&gt;Soit une question vous sera posée et la réponse devra être entrée dans un checker certitude. &lt;span style="color:#e74c3c;"&gt;Si elle comprend plusieurs parties, les mots devront être écrits en majuscules, sans accents, les nombres en chiffres et toutes les parties devront être collées ensemble.&lt;/span&gt; Une bonne réponse entrainera la réception des coordonnées nord ou est de la boite finale. Conservez-les.&lt;/p&gt;

&lt;p&gt;Soit vous devrez encore découvrir les coordonnées. Comme elles seront en deux parties (nord et est), il faudra aussi les conserver pour les entrer ensemble dans le checker.&lt;/p&gt;

&lt;p&gt;Bon amusement !&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Pour réaliser le premier puzzle, cliquez sur le lien suivant :&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;.&lt;/p&gt;

&lt;p style="text-align:center;"&gt;&lt;a href="https://www.jigidi.com/solve/h15bo764/28-a/"&gt;&lt;img alt src="https://img.geocaching.com/cache/large/5ab61dea-f76f-473b-b6a9-9aefd73653a8.png?rnd=0.3294783" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;.&lt;/p&gt;

&lt;p style="text-align:center;"&gt;&lt;a href="https://www.certitudes.org/certitude?wp=W1A02MK"&gt;&lt;img src="https://www.certitudes.org/logo?wp=W1A02MK" title="Cliquer pour voir la liste des utilisateurs ayant résolu l'énigme" /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span style="font-family:Comic Sans MS;"&gt;Vous pouvez valider votre solution d'énigme avec &lt;a href="https://www.certitudes.org/certitude?wp=W1A02MK"&gt;certitude&lt;/a&gt;.&lt;/span&gt;&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Pour réaliser le second puzzle, cliquez sur le lien suivant :&lt;/p&gt;

&lt;p&gt;.&lt;/p&gt;

&lt;p style="text-align:center;"&gt;&lt;a href="https://www.jigidi.com/solve/zp88ye9u/28-b/"&gt;&lt;img alt src="https://img.geocaching.com/cache/large/5ab61dea-f76f-473b-b6a9-9aefd73653a8.png?rnd=0.3294783" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;.&lt;/p&gt;

&lt;p style="text-align:center;"&gt;&lt;a href="https://www.certitudes.org/certitude?wp=W2A02MK"&gt;&lt;img src="https://www.certitudes.org/logo?wp=W2A02MK" title="Cliquer pour voir la liste des utilisateurs ayant résolu l'énigme" /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span style="font-family:Comic Sans MS;"&gt;Vous pouvez valider votre solution d'énigme avec &lt;a href="https://www.certitudes.org/certitude?wp=W2A02MK"&gt;certitude&lt;/a&gt;.&lt;/span&gt;&lt;/p&gt;</groundspeak:long_description>
    <groundspeak:encoded_hints></groundspeak:encoded_hints>
   <groundspeak:logs>
  </groundspeak:logs>
   <groundspeak:travelbugs>
   </groundspeak:travelbugs>
</groundspeak:cache>
</wpt>


Dat op lijn 11 is een namespace:
groundspeak:container.

[size=xsmall]Toevoeging op 19/02/2023 09:54:07:[/size]

https://www.php.net/manual/en/simplexmlelement.getnamespaces.php

Kijk hier over hoe je die aanroept.
En zet je code/lap xml aub tussen codetags. We vinden het fijn als je het forum leesbaar houdt.
oke maar dit moet ik kunnen lezen.
Maar het gaat beter tussen code-tags. ..

Ik had dit al eerder gevraagd. Lees anders de Veelgestelde Vragen op deze site en lees je even in over de opmaakcodes voor in het forum.

Dus pas je bericht aan, en zet er code-tags omheen.
Sorry zal er op letten.

Denk dat ik te oud ben om jullie goed te begrijpen, het gaat er ook zo vlug niet meer in .

Als ik het volgende doe krijg ik terug foutmeldingen op groundspeak :

Warning: simplexml_load_file(): c:/geo_db/test.gpx:21: namespace error : Failed to parse QName 'xmlns:groundspeak:' in C:\xampp\htdocs\geo_db_gpx_gsak\test1.php on line 4


<?php
header ('Content-type: text/html; charset=utf8mb4');

$xml=simplexml_load_file("c:/geo_db/test.gpx") or die("Error: Cannot create object");
$sxe=new SimpleXMLElement($xml);
$ns=$sxe->getNamespaces(true);
var_dump($ns);
?>


Blijkbaar niet eenvoudig om een gpx uit te lezen ..??? op deze manier.
Ik ben er naar aan het kijken, maar die XML is zo corrupt als het maar kan zijn.
Waar heb je die vandaan?

Een error die ik krijg is dit:

The prefix "groundspeak" for element "groundspeak:cache" is not bound.


De tag </gpx> miste aan het eind.
Nu kan ik hem wel goed inladen, maar het geeft wel een berg warnings door brakke namespaces.

Reageren