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

Accessing elements and attributes using SimpleXML

This recipe will explain how we can get the values of the node and/or attributes from an XML file using SimpleXML methods. We will write an example using our common.xml file that will be used to get the publication year or list of stories in a selected book.

Getting ready

Create a folder for this recipe in the Chapter3 directory and name it as Recipe2.

How to do it...

  1. Create a new file named index.php in Recipe2 folder. In this file, create a select box and create its options, which will be the names of books in the common.xml file. Next, create two buttons that will get the publication year and list of stories in the selected book. Each of these buttons has an ID attribute that will be used to distinguish ...

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