I have an XML file named "apps.xml" and structured like this:
<?xml version="1.0" encoding="utf-8"?>
<applications>
<app id="b461ae4a" valid="0" company="Lemon Inc." appname="None" user="admin" description="Test" note="None" />
<app id="1c94395b" valid="0" company="Lemon Inc." appname="None" user="admin" description="Test" note="None" />
</applications>
and I wish to be able to Add, Modify and Update (Save changes to the file) the above mentioned XML file using PHP script ($_GET), DOM and Xpath running on my website.
after Adding a new XML entry (last line), the file output would look like this:
<?xml version="1.0" encoding="utf-8"?>
<applications>
<app id="b461ae4a" valid="0" company="Lemon Inc." appname="None" user="admin" description="Test" note="None" />
<app id="1c94395b" valid="0" company="Lemon Inc." appname="None" user="admin" description="Test" note="None" />
<app id="d65k274p" valid="0" company="Lemon Inc." appname="None" user="admin" description="Test" note="None" />
</applications>
and after Modification/Update (first entry modified/updated) would look like this:
<?xml version="1.0" encoding="utf-8"?>
<applications>
<app id="b461ae4a" valid="1" company="Orange Inc." appname="None" user="tommy" description="Test" note="None" />
<app id="1c94395b" valid="0" company="Lemon Inc." appname="None" user="admin" description="Test" note="None" />
<app id="d65k274p" valid="0" company="Lemon Inc." appname="None" user="admin" description="Test" note="None" />
</applications>
and to add more example what I'm trying to achieve:
http://www.myadress.com/apps.php?append=1&id=d65k274p&valid=1&company=Orange%20Inc&appname=None&user=admin&description=Test¬e=None
// Append argument would decide to add a whole new entry set to 1 or if it is on 0 then to be modified the whole entry by given "id".
$xappend = $_GET["append"];
$xid = $_GET["id"];
$xvalid = $_GET["valid"];
$xcompany = $_GET["company"];
$xappname = $_GET["appname"];
$xuser = $_GET["user"];
$xdescription = $_GET["description"];
$xnote = $_GET["note"];
if (file_exists('apps.xml')) {
$xorig = simplexml_load_file('apps.xml');
} else {
exit('Failed to open apps.xml !');
}
Any help would be highly appreciated!