Create an application that reads "Sports.xml" file into simple XML object. Display attributes and elements. (Hint: Use simple_xml_load_file() function)
<?xml version="1.0" ?>
<?xml-stylesheet
type="text/css"?>
<sportinfo>
<sport
code="B1">
<sname>Cricket</sname>
<captonname>Dhoni</captonname>
</sport>
<sport
code="B2">
<sname>Football</sname>
<captonname>XYZ</captonname>
</sport>
</sportinfo>
Sport.php
<html>
<head>
</head>
<body>
<?php
$xml=simplexml_load_file('slip23.xml')or
die("cannot die");
?>
<center>
</b>Sport
details</b></center>
<table
border="1">
<tr>
<th>Sport
code</th>
<th>Sname</th>
<th>Captonname
</th>
</tr>
<?php
foreach($xml->sport
as $a)
{
echo"<tr><td>".$a['code']."</td>";
echo"<td>".$a->sname."</td>";
echo"<td>".$a->captonname."</td></tr>";
}
?>
</table>
</body>
</html>