TY_BCA_AWT_SLIP 25_2



25.  Create a 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) 



XML file :

<?xml version='1.0' encoding ='UTF-8' ?>
<bookstore>
            <books category="technical">
                        <book_no>1</book_no>
                        <book_name>def</book_name>
                        <author_name>xxx</author_name>
                        <price>100</price>
                        <year>1990</year>
            </books>
            <books category="Cooking">
                        <book_no>2</book_no>
                        <book_name>ccc</book_name>
                        <author_name>aaa</author_name>
                        <price>200</price>
                        <year>1950</year>
            </books>
            <books category="YOGA">
                        <book_no>3</book_no>
                        <book_name>ddd</book_name>
                        <author_name>zzz</author_name>
                        <price>150</price>
                        <year>2016</year>
            </books>
</bookstore>

Php file :

<?php
$xml=simplexml_load_file("slip_24.xml") or die("eror:cannot create object");
var_dump($xml);
?>


No comments:

Post a Comment

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