Modifying an XML using DOM extension
Apart from creating a new XML from scratch as in the previous recipe, we can modify existing XML files too. We can add and remove elements from them.
In this recipe, we will create an example that will allow you to add new stories for a particular book. You will be able to add a title and quote for the selected book.
Getting ready
Create a new folder Recipe6
in the Chapter3
directory.
How to do it...
Create a new file named
index.php
. Next, create a form that has a list of books and two input fields for entering story name and a quote. Also, create a button that will be used to add the new story and the quote to the XML file.<html> <head> <title>Modifying xml with</title> <style type="text/css"> ul{border:1px solid black;padding:5px;list-style:none;width:350px;} label{float:left;width:100px;} </style> </head> <body> <ul> <li> <label for="bookList">Book...