Create an xml file which should comprise the following:
<cricket>
<player>Sachin Tendulkar</player>
<runs>2000</runs>
<wickets> 100</wickets>
<noofnotout>20</noofnotout>
</cricket>
For at least 5 players.
Write a PHP script to display the details of players who have scored more than
1200 runs and at least 50 wickets.
Cricket.xml
<?xml
version="1.0"?>
<?xml-stylesheet
type="text/css"?>
<cricketinfo>
<cricket>
<player>Sachin
Tendulkar</player>
<runs>2000</runs>
wickets> 100</wickets>
<noofnotout>20</noofnotout>
</cricket>
<player>Rohit
Sharma</player>
<runs>1000</runs>
<wickets>40</wickets>
<noofnotout>10</noofnotout>
</cricket>
<cricket>
<player>Dhoni</player>
<runs>1000</runs>
<wickets>40</wickets>
<noofnotout>10</noofnotout>
</cricket>
<cricket>
<player>Virat
Kohali</player>
<runs>1000</runs>
<wickets>40</wickets>
<noofnotout>10</noofnotout>
</cricket>
<cricket>
<player>Jadeja</player>
<runs>1000</runs>
<wickets>40</wickets>
<noofnotout>10</noofnotout>
</cricket>
</cricketinfo>
Cricket.php
<?php
//$xml_data =
simplexml_load_file("http://localhost/arprogram/cricket.xml") or
//die("Error:
Object Creation failure");
$xml_data =
simplexml_load_file("http://localhost:8080/SEM4/cricket.xml") or
die("Error: Object
Creation failure");
foreach
($xml_data->children() as $data)
{
//display each sub element in xml file
$run=$data->runs;
$wic=$data->wickets;
$name=$data->player;
if($run >=1200
&& $wic >= 50)
{
echo
"<br>------------------------------------";
echo
"<br>".$name;
}
}