Update RSS file from another XML file

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"?>

    <catalogue>
      <record>
        <catId>001</catId>
        <title>Fungus</title>
        <location>NPD</location>
        <photographer>jj</photographer>
        <equipment>Canon EOS 40D</equipment>
        <caption>Small fungus</caption>
        <notes>fungus</notes>
        <date>10/8/2012</date>
        <imageUrl>images/IMG_1684.jpg</imageUrl>
      </record>
     </catalogue>

This is the RSS file - rss.xml

<?xml version="1.0" encoding="utf-8"?>
    <rss version="2.0">

    <channel>
      <title>Photo Catalogue Updates</title>
      <link></link>
      <description></description>
      <item>
        <title>Fungus</title>
        <link>images/IMG_3036.jpg</link>
        <description>A new image has been uploaded</description>
      </item>
    </channel>
    </rss>

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

<!doctype html>
    <html>
    <head>
    <meta charset="UTF-8">
    <title>Untitled Document</title>
    </head>

    <body>

    <?php
    $uploadDir = 'images/';

    if(isset($_POST['upload']))
    {
    $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";
                    exit;
                  }

    }

    $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");
    $catId->appendChild(
        $doc->createTextNode( $record["catId"] )
    );
    $b->appendChild( $catId );

    $title = $doc->createElement("title");
    $title->appendChild(
        $doc->createTextNode( $record["title"] )
    );
    $b->appendChild( $title );

    $location = $doc->createElement("location");
    $location->appendChild(
        $doc->createTextNode( $record["location"] )
    );
    $b->appendChild( $location );

    $photographer = $doc->createElement("photographer");
    $photographer->appendChild(
        $doc->createTextNode( $record["photographer"] )
    );
    $b->appendChild( $photographer );

    $equipment = $doc->createElement("equipment");
    $equipment->appendChild(
        $doc->createTextNode( $record["equipment"] )
    );
    $b->appendChild( $equipment );

    $caption = $doc->createElement("caption");
    $caption->appendChild(
        $doc->createTextNode( $record["caption"] )
    );
    $b->appendChild( $caption );

    $notes = $doc->createElement("notes");
    $notes->appendChild(
        $doc->createTextNode( $record["notes"] )
    );
    $b->appendChild( $notes );

    $date = $doc->createElement("date");
    $date->appendChild(
        $doc->createTextNode( $record["date"] )
    );
    $b->appendChild( $date );


    $imageUrl = $doc->createElement("imageUrl");
    $imageUrl->appendChild(
        $doc->createTextNode( $record["imageUrl"] )
    );
    $b->appendChild( $imageUrl );

    $r->appendChild( $b );

    $doc->save("catalogue.xml");

    /* 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_title->appendChild(
        $rss_doc->createTextNode( $record["title"] )
    );
    $rss_b->appendChild( $rss_title );


    $rss_a->appendChild( $rss_b );

    $rss_doc->save("rss.xml");



    header("Location: {$_SERVER['HTTP_REFERER']}");

    ?>

    </body>
    </html>

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.