Slip 20 - A) Create a XML file which gives details of movies available in “Venus CD Store” from following categories a) Classical b) Action c) Horror Elements in each category are in the following format ---- ---- ----- Save the file with name “movies.xml”.

Solution:

<html>

<head>

<link rel="stylesheet" type="text/css" href="book.css">

</head>

<body>

<?php

$xml=simplexml_load_file('movie.xml')or die("cannot die");

?>

<center>

</b>CD details</b></center>

<table border="1">

<th>cdcode</th>

<th>mname</th>

<th>ryear</th>

<th>aname</th>

<?php

foreach($xml->category  as $a)

{

echo"<tr><td>".$a['code']."</td>";

echo"<td>".$a->mname."</td>";

echo"<td>".$a->ryear."</td>";

echo"<td>".$a->aname."</td></tr>";

}

?>

</table>

</body>

</html>


Movie.xml


<?xml version="1.0" ?>

<bookinfo>

<category code="classical">

<mname>Geet</mname>

<ryear>1974</ryear>

<aname>jitendra</aname>

</category>

<category code="action">

<mname>Pushpa</mname>

<ryear>2022</ryear>

<aname>Allu</aname>

</category>

</bookinfo>

Post a Comment

0 Comments