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

Creating an XML using DOM extension

DOM extension gives us the ability to create whole new documents using its numerous functions. In this recipe you will learn how to create new XML documents using DOM functions. As you know we have multiple book elements in our common.xml file, we will create a similar book element with name and story elements using DOM methods.

Getting ready

Create a new folder Recipe5 in the Chapter3 directory.

How to do it…

  1. Create a file and name it index.php in the Recipe5 folder.
  2. Write the PHP code that will create a new XML document, then create some elements and add these to the new document. Some of these elements will have text as well as attributes and their values. Finally, this XML will be saved on the disk.
    <?php $objXML ...

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