Advertisement

04.15.2008 at 11:09AM PDT, ID: 23324660
[x]
Attachment Details

Update an XML file using a PHP script

Asked by Dreammonkey in PHP Scripting Language, Extensible Markup Language (XML)

Tags:

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,$element_name,$element_attrs)
{
      $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
[+][-]04.15.2008 at 04:31PM PDT, ID: 21363657

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]04.16.2008 at 02:07AM PDT, ID: 21365901

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.16.2008 at 10:53AM PDT, ID: 21370289

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.18.2008 at 05:41AM PDT, ID: 21385210

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: PHP Scripting Language, Extensible Markup Language (XML)
Tags: PHP , XML
Sign Up Now!
Solution Provided By: Dreammonkey
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628