Wednesday, 4 May 2022

Advance PHP Slip3b-Write a script to create "cricket.xml" file with multiple elements as shown below: _ Write a script to add multiple elements in "cricket.xml" file of category, country="India".

 Write a script to create "cricket.xml" file with multiple elements as shown below:

<CricketTeam>

<Team country="Australia">

<player>_ </player> <runs> </runs> <wicket> </wicket>

</Team>

</Cricket Team> Write a script to add multiple elements in "cricket.xml" file of category, country="India".

 

CricketTeam.xml

 

<?xml version="1.0" ?>

 

<CricketTeam>

<Team country="India">

<player>sachin</player>

<runs>36000</runs>

<wicket>88</wicket>

</Team>

 

<Team country="Australia">

<player>watsun</player>

<runs>10000</runs>

 <wicket>49</wicket>

 </Team>

 

 <Team country="Pakisthan">

<player>wasim</player>

<runs>6000</runs>

<wicket>79</wicket>

</Team>

 </CricketTeam>

 

 CricketTeam.php

 

<?php

  $xml=simplexml_load_file("CricketTeam.xml") or die("cannnot load");

 $xmlstring=$xml->asXML();

 echo $xmlstring;                         

?>