Create a simple XML file to store information about three books, including title, author, and price. Then, write a PHP script to read and display the data

 :


.


Source Code:


q34.xml


<bookstore>


<book>


<title>Goosbumps</title>


<author>R.L Stire</author>


<price>300</price>


</book>


<book>


<title>Spiderman</title>


<author>Stan Lee</author>


<price>550</price>


</book>


<book>


<title>My Life My Message</title>


<author>Mahatma Gandhi</author>


<price>600</price>


</book>


</bookstore>


q34.php


<?php


xml=simplexml_load_file("q34.xml") or die("Error: cannot create an object");


$ echo"<h1>The Books are:<h1>";


foreach($xml->book as $book) [


echo"<h3>Title:".$book->title."<br></h3>";


echo"<h3>Author:" Sbook->author."<br></h3>";


echo"<h3>Price:" $book->price."<br></h3>";


1

Comments

Popular posts from this blog

Calculate Factorial using While loop in JavaScript.

Calculator

Simple calculator