Create an application that reads “Book.xml” into simple XML object. Display attributes and elements. (Hints:- use simplexml_load_file() function).

BOOK.XML

<?xml version="1.0" encoding="utf-8"?>
<BOOKINFO>
      <BOOK>
        <bookname>ABC</bookname>
        <author>pqr</author>
        <price>400</price>
      </BOOK>
      <BOOK>
        <bookname>DEF</bookname>
        <author>xyz</author>
        <price>300</price>
      </BOOK>
</BOOKINFO>


BOOK.PHP

<?php
    $xml=simplexml_load_file("Book.xml") or die("cannnot load");
   $xmlstring=$xml->asXML();
   echo $xmlstring;
?>

Comments

Popular posts from this blog

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). 

Write a script to solve following questions(use “Book.xml” file) A:- Create a Dom document object and load this xml file. B:- Get the output of this document to the browser. C:- Save this [.xml] document in another format that i.e. in [.doc]. D:- Write a xml program to print the names of the books available in “Book.xml” file.

Write a simple PHP program which implements Ajax for addition of two numbers