Slip no. 5 . Write a script to create XML file as ‘Employee.xml’. The element of this xml file are as follows:
<Employee EMPno= Empname=>

XML file :  employee.xml
<?xml version="1.0" encoding="UTF-8"?>
                <Emp Empno="1" Empname="Mansi">
                <Emp Empno="2" Empname="Gautam">
                <Emp Empno="3" Empname="Jack">

PHP file :
                $xml=simplexml_load_file("employee.xml") or die("eror:cannot create object");

                echo "<table border=1 align=center>";
                echo "<tr><td>Employee no</td><td>Employee Name</td><td>Employee Salary</td><td>Employee Employee Designation</td></tr>";

                foreach($xml->children() as $emp)
                                $arr = $emp->attributes(); 
                                echo "<tr><td>".$arr["Empno"]."</td>";
                                echo "<td>".$arr["Empname"]."</td>";
                                echo "<td>".$emp->Sal."</td>";
                                echo "<td>".$emp->Desg."</td></tr>";

                echo "<table>";

No comments:

Post a comment

Note: only a member of this blog may post a comment.