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.
Result of php executing
Full code of xmlreader.php
- <?php
- <?php
- $xml=<<<'EOD'
- <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">
- <request_index>42054019</request_index>
- <data_source name="metars"/>
- <request type="retrieve"/>
- <errors/>
- <warnings/>
- <time_taken_ms>5</time_taken_ms>
- <data num_results="1">
- <METAR>
- <raw_text>SUMU 031200Z 03011KT CAVOK 26/17 Q1017 NOSIG</raw_text>
- <station_id>SUMU</station_id>
- <observation_time>2020-02-03T12:00:00Z</observation_time>
- <latitude>-34.82</latitude>
- <longitude>-56.0</longitude>
- <temp_c>26.0</temp_c>
- <dewpoint_c>17.0</dewpoint_c>
- <wind_dir_degrees>30</wind_dir_degrees>
- <wind_speed_kt>11</wind_speed_kt>
- <visibility_statute_mi>6.21</visibility_statute_mi>
- <altim_in_hg>30.029528</altim_in_hg>
- <quality_control_flags>
- <no_signal>TRUE</no_signal>
- </quality_control_flags>
- <sky_condition sky_cover="CAVOK"/>
- <flight_category>VFR</flight_category>
- <metar_type>METAR</metar_type>
- <elevation_m>32.0</elevation_m>
- </METAR>
- </data>
- </response>
- EOD;
- print_r($xml);
- $xmlr = new XMLReader();
- $xmlr->XML($xml);
- $xmlr->read();
- var_dump($xmlr);