O'Reilly logo

PHP jQuery Cookbook by Vijay Joshi

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Reading an XML using DOM extension

In this recipe, you will see the use of PHP's DOM extension to read an XML and extract information from it. We will create an example where we will display a list of books. Clicking a book name will reveal the list of stories in that book.

Getting ready

Create a folder Recipe4 in the Chapter3 directory and make sure you have common.xml file accessible.

How to do it...

  1. Create an index.php file in the Recipe4 folder. In the HTML markup, write the PHP code that will load the XML using DOM methods. From the loaded XML, create h1 sections that will contain the book name and its publication year.
  2. Under each h1, create an unordered list of stories in that book. Note that in the<head> section, we have hidden ul using display ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required