Solution:
<?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>
0 Comments