xml - 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 xml.php
- <?php
- $str ='<Events>
- <Event>
- <Name>Movie One</Name>
- <Times>
- <EventTime>
- <Time>2019-02-10T14:30:00</Time>
- <Capacity>100</Capacity>
- </EventTime>
- </Times>
- </Event>
- <Event>
- <Name>Movie One</Name>
- <Times>
- <EventTime>
- <Time>2019-02-11T18:30:00</Time>
- <Capacity>100</Capacity>
- </EventTime>
- </Times>
- </Event>
- <Event>
- <Name>Movie One</Name>
- <Times>
- <EventTime>
- <Time>2019-02-12T18:30:00</Time>
- <Capacity>100</Capacity>
- </EventTime>
- </Times>
- </Event>
- </Events>';
- $xml=simplexml_load_string($str) or die("Error: Not Working");
- foreach($xml->children() as $cinemalist) {
- echo '<p>Event Name: ' . $cinemalist->Name . " </p> ";
- foreach($cinemalist->children() as $alltimes) {
- $showtimes = $alltimes->EventTime->Time;
- echo '<span>' . $showtimes . " </span> ";
- }
- }