Ik loop tegen het volgende probleem aan.
De query, mijn code ziet er als volgt uit:
<?php
echo <<<EOF
<table>
<tr>
<th>Kenteken</th>
<th>Laadvermogen</th>
<th>Merk</th>
<th>Milieuclassificatie</th>
<th>Nevenbrandstof</th>
</tr>
EOF;
//$xml = new SimpleXMLElement('https://api.datamarket.azure.com/opendata.rdw/VRTG.Open.Data/v1/KENT_VRTG_O_DAT', null, true);
$xml = simplexml_load_file("https://api.datamarket.azure.com/opendata.rdw/VRTG.Open.Data/v1/KENT_VRTG_O_DAT");
$xml->registerXPathNamespace('m','http://schemas.microsoft.com/ado/2007/08/dataservices/metadata');
foreach ($xml->xpath('//m:properties') as $title)
{
$row = simplexml_load_string($title->asXML());
$row->registerXPathNamespace('d', 'http://schemas.microsoft.com/ado/2007/08/dataservices');
$v = $row->xpath('//d:Kenteken[. ="0001ES"]');
if($v[0]){
echo <<<EOF
<tr>
<td>{$title->Kenteken}</td>
<td>{$title->Laadvermogen}</td>
<td>{$title->Merk}</td>
<td>{$title->Milieuclassificatie}</td>
<td>{$title->Nevenbrandstof}</td>
</tr>
EOF;
}
}
?>
Wat ik wil is dat als het kenteken "0001ES" is hij alle gegevens van die kenteken laat zien. Ik heb toen straks een code gehad waar hij dus wel alleen "0001ES" laat zien maar ik kon toen niet bij de andere gegevens die bij die kenteken horen.
Ik heb al verschillende constructies van internet afgehaald waaronder deze die ik nu heb. Misschien mis ik iets heel simpels maar ik hoop dat iemand mij kan helpen.
om even een kort voorbeeld te geven hoe de .xml file eruit ziet(kan ook via de URL)
<entry>
<content>
<m:properties>
<d:Aantalcilinders m:type="Edm.Int16">4</d:Aantalcilinders>
<d:Aantalstaanplaatsen m:type="Edm.Int16" m:null="true" />
<d:Aantalzitplaatsen m:type="Edm.Int16" m:null="true" />
<d:BPM m:type="Edm.Int32" m:null="true" />
<d:Brandstofverbruikbuitenweg m:type="Edm.Decimal" m:null="true" />
<d:Brandstofverbruikgecombineerd m:type="Edm.Decimal" m:null="true" />
<d:Brandstofverbruikstad m:type="Edm.Decimal" m:null="true" />
<d:Catalogusprijs m:type="Edm.Int32" m:null="true" />
</m:properties>
</content>
</entry>