I am not sure how to do this?

I want to be able to update an xml file (which I can do) and then have the rss feed atomically updated from this xml file. Hope this makes sense.

I can update and show the data from my XML file. I do this with XSL and some PHP.

I can create and show the data from an RSS file.

I dont know how to link the two so when I update the XML file it updates the details in the RSS file.

Hope this makes sense.

This is the xml file - catalogue.xml

<?xml version="1.0" encoding="utf-8"?>
    <?xml-stylesheet type="text/xsl" href="catalogue.xsl"?>
        <equipment>Canon EOS 40D</equipment>
        <caption>Small fungus</caption>

This is the RSS file - rss.xml

<?xml version="1.0" encoding="utf-8"?>
    <rss version="2.0">
      <title>Photo Catalogue Updates</title>
        <description>A new image has been uploaded</description>

Below is the php code I am trying to get working:

<!doctype html>
    <meta charset="UTF-8">
    <title>Untitled Document</title>
    $uploadDir = 'images/';
    $fileName = $_FILES['userfile']['name'];
    $tmpName = $_FILES['userfile']['tmp_name'];
    $fileSize = $_FILES['userfile']['size'];
    $fileType = $_FILES['userfile']['type'];
    $filePath = $uploadDir . $fileName;
    $result = move_uploaded_file($tmpName, $filePath);
    if (!$result) {
                    echo "Error uploading file";
    $record = array(
    	'catId' => $_POST['catId'],
        'title' => $_POST['title'],
        'location' => $_POST['location'],
    	'photographer' => $_POST['photographer'],
        'equipment' => $_POST['equipment'],
    	'caption' => $_POST['caption'],
        'notes' => $_POST['notes'],
    	'date' => $_POST['date'],
        'imageUrl' => $filePath,
    $doc = new DOMDocument('1.0');
    $doc->formatOutput = true;
    $doc->preserveWhiteSpace = false;
    $doc->load( 'catalogue.xml' );
    $r = $doc->getElementsByTagName("catalogue")->item(0);
    $b = $doc->createElement("record");
    $catId = $doc->createElement("catId");
        $doc->createTextNode( $record["catId"] )
    $b->appendChild( $catId );
    $title = $doc->createElement("title");
        $doc->createTextNode( $record["title"] )
    $b->appendChild( $title );
    $location = $doc->createElement("location");
        $doc->createTextNode( $record["location"] )
    $b->appendChild( $location );
    $photographer = $doc->createElement("photographer");
        $doc->createTextNode( $record["photographer"] )
    $b->appendChild( $photographer );
    $equipment = $doc->createElement("equipment");
        $doc->createTextNode( $record["equipment"] )
    $b->appendChild( $equipment );
    $caption = $doc->createElement("caption");
        $doc->createTextNode( $record["caption"] )
    $b->appendChild( $caption );
    $notes = $doc->createElement("notes");
        $doc->createTextNode( $record["notes"] )
    $b->appendChild( $notes );
    $date = $doc->createElement("date");
        $doc->createTextNode( $record["date"] )
    $b->appendChild( $date );
    $imageUrl = $doc->createElement("imageUrl");
        $doc->createTextNode( $record["imageUrl"] )
    $b->appendChild( $imageUrl );
    $r->appendChild( $b );
    /* ABOVE here works fine*/

    /*problem bits below - trying to load rss.xml and update it*/
    $rss_doc = new DOMDocument('1.0');
    $rss_doc->formatOutput = true;
    $rss_doc->preserveWhiteSpace = false;
    $rss_doc->load( 'rss.xml' );
    $rss_a = $rss_doc->getElementsByTagName("rss")->item(0);
    $rss_b = $rss_doc->createElement("channel");
    $rss_title= $rss_doc->createElement("title");
        $rss_doc->createTextNode( $record["title"] )
    $rss_b->appendChild( $rss_title );
    $rss_a->appendChild( $rss_b );
    header("Location: {$_SERVER['HTTP_REFERER']}"); 

Basically I just need to inform the user via RSS that a new image has been added.

I am assuming I can use the original array details ($record) to update the rss.xml?

Thanks for any advice.