Slip 17 - B) Write a script to create XMLfile “University.xm1l”. The elements details of “University.xml” are as follows : --------- --. -. - 1) Store the details of at least 3 universities. 2) Link the “University.xm1’ file to css and get well formatted outputas given below.... i) Uname : Color: black ; Font-family : copperplate Gothic Light; Font-size : 16 pt Font : Bold; ii) City and Rank : Color : Yellow; Font-family : Arial ; Font-size : 12 pt Font : Bold;

 Solution:

XML file : university.xml

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="university.css"?>
<Uni>
                <U_info>
                                <Uname>Pune University</Uname>
                                <City>Pune</City>
                                <Rank>First</Rank>
                </U_info>
                <U_info>
                                <Uname>Mumbai University</Uname>
                                <City>Mumbai</City>
                                <Rank>Third</Rank>
                </U_info>
                <U_info>
                                <Uname>Latur University</Uname>
                                <City>Latur</City>
                                <Rank>Fifth</Rank>
                </U_info>
</Uni>

CSS file : university.css

Uname
{
                color:black;
                font-family: copperplate Gothic Light;
                font-size: 16pt;
                font: bold;
}
City,Rank
{
                color:yellow;
                font-family:arial;
                font-size: 12pt;
                font: bold;
}

PHP file :


<?php
                $xml=simplexml_load_file("university.xml") or die("eror:cannot create object");
                echo "<table border=1 align=center>";
                echo "<tr><td>Univercity Name</td><td>City</td><td>Rank</td></tr>";
                foreach($xml->children() as $uni)
                {
                                echo "<tr><td>".$uni->Uname."</td>";
                                echo "<td>".$uni->City."</td>";
                                echo "<td>".$uni->Rank."</td></tr>";
                }
                echo "<table>";
?>

Post a Comment

0 Comments