I'm making an interface-website to update a concert-list on a band-website.
The list is stored as an XML file an has this structure :
<?xml version='1.0' encoding='ISO-8859-1'?>
<gigs><gig id="1" day="01" month="01" year="2000" venue="New York" /></gigs>
<gigs><gig id="2" day="02" month="01" year="2000" venue="Berlin" /></gigs>
I already wrote a script that enables me to add a new gig to the list, this was relatively easy...
Now I want to write a script that enables me to edit a certain gig in the list.
Every Gig is Unique because of the first attribute : "id" .
I want to use this reference to edit the other attributes in that Node.
My PHP is very poor, so I hope someone could put me on the good foot here...
My PHP script :
<?php
$id = $_POST['id'];
$day = $_POST['day'];
$month = $_POST['month'];
$year = $_POST['year'];
$venue = $_POST['venue'];
$xml_file="gig.xml";
$fh = fopen($xml_file,'r');
$current_tag=" ";
function start_element($parser,$ele
ment_name,
$element_a
ttrs)
{
$current_tag = $element_name;
if($element_name == 'GIG' && $element_attrs["ID"] == $id)
{
echo 'gig ID =' . $id;
// here the new info has to replace the old
};
};
if($fh) {
echo "&verify=success&";
} else {
echo "&verify=fail&";
}
fclose($fh);
?>
Start Free Trial