lezen xml file
Heb een probleem
de file ziet er als volgt uit :
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?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 http://www.gsak.net/xmlv1/6 http://www.gsak.net/xmlv1/6/gsak.xsd"
xmlns="http://www.topografix.com/GPX/1/0">
<desc>Geocache file generated by GSAK (HasChildren)</desc>
<author>GSAK</author>
<email>[email protected]</email>
<time>2023-11-24T16:25:32Z</time>
<keywords>cache, geocache, groundspeak</keywords>
<bounds minlat="45.85205" minlon="6.10135" maxlat="45.85205" maxlon="6.10135"/>
<wpt lat="45.85205" lon="6.10135">
<time>2019-04-05T08:00:00Z</time>
<name>GC85BK6</name>
<desc>Vire dans le Semnoz S14. by GUYCAT (2,5/2,5)</desc>
<url>http://coord.info/GC85BK6</url>
<urlname>Vire dans le Semnoz S14. by GUYCAT</urlname>
<sym>Geocache</sym>
<type>Geocache|Unknown Cache</type>
<gsak:wptExtension xmlns:gsak="http://www.gsak.net/xmlv1/6">
<gsak:UserFlag>false</gsak:UserFlag>
<gsak:Lock>false</gsak:Lock>
<gsak:DNF>false</gsak:DNF>
<gsak:Watch>false</gsak:Watch>
<gsak:UserData></gsak:UserData>
<gsak:LatBeforeCorrect>45.848433</gsak:LatBeforeCorrect>
<gsak:LonBeforeCorrect>6.101</gsak:LonBeforeCorrect>
<gsak:StateBeforeCorrect>Auvergne-Rhne-Alpes</gsak:StateBeforeCorrect>
<gsak:CountyBeforeCorrect></gsak:CountyBeforeCorrect>
<gsak:FirstToFind>false</gsak:FirstToFind>
<gsak:User2></gsak:User2>
<gsak:User3></gsak:User3>
<gsak:User4></gsak:User4>
<gsak:County></gsak:County>
<gsak:UserSort>0</gsak:UserSort>
<gsak:SmartName>VireDa14</gsak:SmartName>
<gsak:LastGpxDate>2023-11-24</gsak:LastGpxDate>
<gsak:Code>GC85BK6</gsak:Code>
<gsak:Resolution></gsak:Resolution>
<gsak:IsPremium>false</gsak:IsPremium>
<gsak:FavPoints>32</gsak:FavPoints>
<gsak:GcNote>Dit is een test</gsak:GcNote>
<gsak:Guid></gsak:Guid>
<gsak:CacheImages>
<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 http://www.gsak.net/xmlv1/6 http://www.gsak.net/xmlv1/6/gsak.xsd"
xmlns="http://www.topografix.com/GPX/1/0">
<desc>Geocache file generated by GSAK (HasChildren)</desc>
<author>GSAK</author>
<email>[email protected]</email>
<time>2023-11-24T16:25:32Z</time>
<keywords>cache, geocache, groundspeak</keywords>
<bounds minlat="45.85205" minlon="6.10135" maxlat="45.85205" maxlon="6.10135"/>
<wpt lat="45.85205" lon="6.10135">
<time>2019-04-05T08:00:00Z</time>
<name>GC85BK6</name>
<desc>Vire dans le Semnoz S14. by GUYCAT (2,5/2,5)</desc>
<url>http://coord.info/GC85BK6</url>
<urlname>Vire dans le Semnoz S14. by GUYCAT</urlname>
<sym>Geocache</sym>
<type>Geocache|Unknown Cache</type>
<gsak:wptExtension xmlns:gsak="http://www.gsak.net/xmlv1/6">
<gsak:UserFlag>false</gsak:UserFlag>
<gsak:Lock>false</gsak:Lock>
<gsak:DNF>false</gsak:DNF>
<gsak:Watch>false</gsak:Watch>
<gsak:UserData></gsak:UserData>
<gsak:LatBeforeCorrect>45.848433</gsak:LatBeforeCorrect>
<gsak:LonBeforeCorrect>6.101</gsak:LonBeforeCorrect>
<gsak:StateBeforeCorrect>Auvergne-Rhne-Alpes</gsak:StateBeforeCorrect>
<gsak:CountyBeforeCorrect></gsak:CountyBeforeCorrect>
<gsak:FirstToFind>false</gsak:FirstToFind>
<gsak:User2></gsak:User2>
<gsak:User3></gsak:User3>
<gsak:User4></gsak:User4>
<gsak:County></gsak:County>
<gsak:UserSort>0</gsak:UserSort>
<gsak:SmartName>VireDa14</gsak:SmartName>
<gsak:LastGpxDate>2023-11-24</gsak:LastGpxDate>
<gsak:Code>GC85BK6</gsak:Code>
<gsak:Resolution></gsak:Resolution>
<gsak:IsPremium>false</gsak:IsPremium>
<gsak:FavPoints>32</gsak:FavPoints>
<gsak:GcNote>Dit is een test</gsak:GcNote>
<gsak:Guid></gsak:Guid>
<gsak:CacheImages>
mijn code is :
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
$file = "test.gpx" ;
$xml = simplexml_load_file($file);
foreach ($xml->wpt as $wpt) {
$Breedtegraad= $wpt['lat'] ;
$Lengtegraad = $wpt['lon'] ;
$gccode= $wpt->name ;
$type = explode('|', $wpt->type)[1] ;
$wpt->registerXPathNamespace('gsak', 'http://www.gsak.net/xmlv1/6');
$wpt->registerXPathNamespace('groundspeak', 'http://www.groundspeak.com/cache/1/0/1');
$c = $wpt->children('groundspeak', true);
$b = $wpt->children('gsak', true);
$oms= $c->cache->name ;
$owner = $c->cache->placed_by ;
$beh= strtoupper($c->cache->container) ;
$moe= $c->cache->difficulty ;
$ter= $c->cache->terrain ;
$land= $c->cache->country ;
$prov= $c->cache->state ;
$note= $b->wptExtension->GcNote ;// dit er laatst bijgemaakt
}
echo $gccode ;
echo $note ;
?>
$file = "test.gpx" ;
$xml = simplexml_load_file($file);
foreach ($xml->wpt as $wpt) {
$Breedtegraad= $wpt['lat'] ;
$Lengtegraad = $wpt['lon'] ;
$gccode= $wpt->name ;
$type = explode('|', $wpt->type)[1] ;
$wpt->registerXPathNamespace('gsak', 'http://www.gsak.net/xmlv1/6');
$wpt->registerXPathNamespace('groundspeak', 'http://www.groundspeak.com/cache/1/0/1');
$c = $wpt->children('groundspeak', true);
$b = $wpt->children('gsak', true);
$oms= $c->cache->name ;
$owner = $c->cache->placed_by ;
$beh= strtoupper($c->cache->container) ;
$moe= $c->cache->difficulty ;
$ter= $c->cache->terrain ;
$land= $c->cache->country ;
$prov= $c->cache->state ;
$note= $b->wptExtension->GcNote ;// dit er laatst bijgemaakt
}
echo $gccode ;
echo $note ;
?>
mijn probleem is dat $note leeg blijft terwijl dit in de file niet zo is.
Alle andere van groundspeak worden wel gelezen.
Waar zit mijn fout AUB ?
Gewijzigd op 24/11/2023 19:56:09 door - Ariën -
heb je het al door var_dump() gehaald?
var_dump() geeft : object(SimpleXMLElement)#15 (0) { }
$gcNoteValue = (string)$xml->wpt->children('http://www.gsak.net/xmlv1/6')->GcNote;
$gcNoteValue blijft leeg
var_dump() geeft : string(0) ""
Toevoeging op 24/11/2023 20:52:32:
Hallo allemaal, heb de oplossing zelf gevonden en het is deze
Top! :-)