xmlreader - PHP Online

Form of PHP Sandbox

Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php in the places where the PHP script should be executed.



Your result can be seen below.

Result of php executing





Full code of xmlreader.php

  1. <?php
  2. <?php
  3. $xml=<<<'EOD'
  4. <response xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XML-Schema-instance" version="1.2" xsi:noNamespaceSchemaLocation="http://aviationweather.gov/adds/schema/metar1_2.xsd">
  5. <request_index>42054019</request_index>
  6. <data_source name="metars"/>
  7. <request type="retrieve"/>
  8. <errors/>
  9. <warnings/>
  10. <time_taken_ms>5</time_taken_ms>
  11. <data num_results="1">
  12. <METAR>
  13. <raw_text>SUMU 031200Z 03011KT CAVOK 26/17 Q1017 NOSIG</raw_text>
  14. <station_id>SUMU</station_id>
  15. <observation_time>2020-02-03T12:00:00Z</observation_time>
  16. <latitude>-34.82</latitude>
  17. <longitude>-56.0</longitude>
  18. <temp_c>26.0</temp_c>
  19. <dewpoint_c>17.0</dewpoint_c>
  20. <wind_dir_degrees>30</wind_dir_degrees>
  21. <wind_speed_kt>11</wind_speed_kt>
  22. <visibility_statute_mi>6.21</visibility_statute_mi>
  23. <altim_in_hg>30.029528</altim_in_hg>
  24. <quality_control_flags>
  25. <no_signal>TRUE</no_signal>
  26. </quality_control_flags>
  27. <sky_condition sky_cover="CAVOK"/>
  28. <flight_category>VFR</flight_category>
  29. <metar_type>METAR</metar_type>
  30. <elevation_m>32.0</elevation_m>
  31. </METAR>
  32. </data>
  33. </response>
  34. EOD;
  35.  
  36.  
  37. print_r($xml);
  38.  
  39. $xmlr = new XMLReader();
  40. $xmlr->XML($xml);
  41. $xmlr->read();
  42. var_dump($xmlr);
File Description
  • xmlreader
  • PHP Code
  • 03 Feb-2020
  • 1.16 Kb
You can Share it: