Jump to content

GRBZ

New Members
  • Posts

    2
  • Joined

  • Last visited

Everything posted by GRBZ

  1. Late answer but big thanks. This works now.
  2. Hi I'm not yet very familiar with PHP, XML and curl, so I need your help. Trying to get flight number, but here is something weird. This is the XML-file I get from Finavia API; <?xml version="1.0" encoding="UTF-8"?> <flights xmlns="http://www.finavia.fi/FlightsService.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <arr> <header> <timestamp>2024-08-22T01:52:35Z</timestamp> <from>Finavia</from> <description>Arrival flight data</description> </header> <body> <flight> <h_apt>KEM</h_apt> <fltnr>AY519</fltnr> <sdt>2024-08-22T16:55:00Z</sdt> <sdate>20240822</sdate> <acreg>OHATH</acreg> <actype>AT75</actype> ................ </flight> </body> </arr> Using this PHP code to get started; <?php $xml = simplexml_load_file('flights.xml'); $otsikot = $xml->xpath('//flight[fltnr="AY456"]/acreg'); // Tulosta tulokset foreach ($otsikot as $otsikko) { echo $otsikko . "<br>"; } ?> This returns empty page, but when I remove lines; <flights xmlns="http://www.finavia.fi/FlightsService.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> It works. Why is this? AI told me to do it like this; $otsikot = $xml->xpath('//flights:flight/flights:fltnr', $xml->getNamespaces()); But this crashes the whole page, so what is wrong and what should I do. Thanks
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.