Create an XML file which gives details of books available in “ABC Bookstore” from following categories. 1) Technical 2) Cooking 3) Yoga And elements in each category are in the following format. ……. ……. ……. Save the file as “Book.xml” Create an application that reads “Book.xml” file into simple XML object. Display attributes and elements. (Hint:- Use simple_xml_load_file() function).
Book.XML
<?xml version="1.0" encoding="utf-8"?>
<ABCBOOK>
<Technical>
<BOOK>
<Book_PubYear>ABC</Book_PubYear>
<Book_Title>pqr</Book_Title>
<Book_Author>400</Book_Author>
</BOOK>
</Technical>
<Cooking>
<BOOK>
<Book_PubYear>ABC</Book_PubYear>
<Book_Title>pqr</Book_Title>
<Book_Author>400</Book_Author>
</BOOK>
</Cooking>
<Yoga>
<BOOK>
<Book_PubYear>ABC</Book_PubYear>
<Book_Title>pqr</Book_Title>
<Book_Author>400</Book_Author>
</BOOK>
</Yoga>
</ABCBOOK>
Book.php
<?php
$xml=simplexml_load_file("Book.xml") or die("cannnot load");
$xmlstring=$xml->asXML();
echo $xmlstring;
?>
<?xml version="1.0" encoding="utf-8"?>
<ABCBOOK>
<Technical>
<BOOK>
<Book_PubYear>ABC</Book_PubYear>
<Book_Title>pqr</Book_Title>
<Book_Author>400</Book_Author>
</BOOK>
</Technical>
<Cooking>
<BOOK>
<Book_PubYear>ABC</Book_PubYear>
<Book_Title>pqr</Book_Title>
<Book_Author>400</Book_Author>
</BOOK>
</Cooking>
<Yoga>
<BOOK>
<Book_PubYear>ABC</Book_PubYear>
<Book_Title>pqr</Book_Title>
<Book_Author>400</Book_Author>
</BOOK>
</Yoga>
</ABCBOOK>
Book.php
<?php
$xml=simplexml_load_file("Book.xml") or die("cannnot load");
$xmlstring=$xml->asXML();
echo $xmlstring;
?>
Comments
Post a Comment