/ Assignment No. 02
Semester: Spring 2017
Introduction to Web Services Development – CS311 / Total Marks: 20
Due Date:May24, 2017
Lectures Covered: 1 to 17
Objectives:
Understand and get hands on experience of
  • PHP server side script
  • Loopin PHP
  • Reading HTML elements in PHP
  • Create XML element using PHP
Instructions:
Please read the following instructions carefully before submitting assignment:
It should be clear that your assignment will not get any credit if:
  • The assignment is submitted after due date.
  • The assignment is submitted via email.
  • The assignment is copied from Internet or from any other student.
  • The submitted assignment does not open or file is corrupt.
  • It is in some format other than .php(PHP Code File).
Note: All types of plagiarism are strictly prohibited.
For any query about the assignment, contact at
You are required to write a program in PHP which will read data from the given below HTML code and generate XML code as given in sample output below.
HTML Code:
<html>
<body>
<table border='1' cellpadding='10' cellspacing='0' align='center'>
<caption<h2>Breakfast_Menu</h2</caption>
<tr>
<td>Sr. #</td>
<td>Type</td>
<td>Name</td>
<td>Price</td>
<td>Descripton</td>
<td>Calories</td>
</tr>
<tr>
<td>1</td>
<td>Food</td>
<td>Belgian Waffles</td>
<td>$5.95</td>
<td>Two of our famous Belgian Waffles with plenty of real maple syrup</td>
<td>650</td>
</tr>
<tr>
<td>2</td>
<td>Food</td>
<td>Strawberry Belgian Waffles</td>
<td>$7.95</td>
<td>Light Belgian waffles covered with strawberries and whipped cream</td>
<td>900</td>
</tr>
<tr>
<td>3</td>
<td>Food</td>
<td>Berry-Berry Belgian Waffles</td>
<td>$8.95</td>
<td>Belgian waffles covered with assorted fresh berries and whipped cream</td>
<td>900</td>
</tr>
<tr>
<td>4</td>
<td>Food</td>
<td>French Toast</td>
<td>$4.50</td>
<td>Thick slices made from our homemade sourdough bread</td>
<td>600</td>
</tr>
<tr>
<td>5</td>
<td>Food</td>
<td>Homestyle Breakfast</td>
<td>$6.95</td>
<td>Two eggs, bacon or sausage, toast, and our ever-popular hash browns</td>
<td>950</td>
</tr>
</table>
</body>
</html>
Sample Output:
<?xml version='1.0' encoding='UTF-8'?>
<Breakfast_Menu>
<Food>
<name>Belgian Waffles</name>
<price>$5.95</price>
<description>
Two of our famous Belgian Waffles with plenty of real maple syrup
</description>
<calories>650</calories>
</Food>
<Food>
<name>Strawberry Belgian Waffles</name>
<price>$7.95</price>
<description>
Light Belgian waffles covered with strawberries and whipped cream
</description>
<calories>900</calories>
</Food>
<Food>
<name>Berry-Berry Belgian Waffles</name>
<price>$8.95</price>
<description>
Belgian waffles covered with assorted fresh berries and whipped cream
</description>
<calories>900</calories>
</Food>
<Food>
<name>French Toast</name>
<price>$4.50</price>
<description>
Thick slices made from our homemade sourdough bread
</description>
<calories>600</calories>
</Food>
<Food>
<name>Homestyle Breakfast</name>
<price>$6.95</price>
<description>
Two eggs, bacon or sausage, toast, and our ever-popular hash browns
</description>
<calories>950</calories>
</Food>
</Breakfast_Menu>
You can also see sample output in “A2 Demo.mp4” video attached with this assignment file.
Assignment Instructions:
In Assignment no. 2 of Fall 2016 (attached with this assignment) student were given a task to use provided XML and generate HTM table using PHP. Please see the assignment, demo video and solution of Fall 2016 assignment.
Now in this assignment you have to use HTML code of previous assignment and generate XML code as output which was input in previous assignment.

Tips:
  • Put whole provided HTML code into a string.
  • UseDOMDocument object for traversing HTML elements
  • Use “&lt;” and “&gt;” for “” and “”symbols.
  • Use LoadHTML function to load HTML from string to DOMDocument object.
  • Use dot(.) operator to concatenate strings to create required output.
  • Use foreach loop to travers all rows/columns of HTML table.
Uploading Instructions:
You need to upload PHP file that contain solution of this assignment. The procedure to use online tool to write, compile, test PHP code and export/downloadit is given in “A2 Demo.mp4” video file.
Please note that due date of assignment will not extended, so do not wait for last date and submit your solution as quickly as possible.
Due Date:Wednesday, May24, 2017.
BEST OF LUCK