Editing XML using PHP for Project Manipulation
I had an idea about creating tutorial that will cover manipulating XML in PHP. The idea was to create some website that will use XML as a database.You can use it for password storage for your website admin and even your website configuration. In this tutorial we'll try to edit some data in XML. Our XML looks like this. Apple 10.25 15 We'll load item element and change it's content. Then we'll create new item element and append it to fruits after first item. So let's start. Loading Document And Elements First we have to create new DOMDocument class instance. We'll set XML version and encoding. Next we'll set formatOutput to true so we can have nice output. We'll also set preserveWhiteSpace to false because there is some bug in PHP that will not save nicely newly created elements. Now we just have to load our XML file. $xml = new DOMDocument('1.0', 'utf-8'); $xml->formatOutput = true; $xml->preserveWhiteSpace = fal...