Note that there are some explanatory texts on larger screens.

plurals
  1. POUpdate RSS file from another XML file
    text
    copied!<p>I am not sure how to do this?</p> <p>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.</p> <p>I can update and show the data from my XML file. I do this with XSL and some PHP.</p> <p>I can create and show the data from an RSS file.</p> <p>I dont know how to link the two so when I update the XML file it updates the details in the RSS file.</p> <p>Hope this makes sense.</p> <p>This is the xml file - catalogue.xml</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;?xml-stylesheet type="text/xsl" href="catalogue.xsl"?&gt; &lt;catalogue&gt; &lt;record&gt; &lt;catId&gt;001&lt;/catId&gt; &lt;title&gt;Fungus&lt;/title&gt; &lt;location&gt;NPD&lt;/location&gt; &lt;photographer&gt;jj&lt;/photographer&gt; &lt;equipment&gt;Canon EOS 40D&lt;/equipment&gt; &lt;caption&gt;Small fungus&lt;/caption&gt; &lt;notes&gt;fungus&lt;/notes&gt; &lt;date&gt;10/8/2012&lt;/date&gt; &lt;imageUrl&gt;images/IMG_1684.jpg&lt;/imageUrl&gt; &lt;/record&gt; &lt;/catalogue&gt; </code></pre> <p>This is the RSS file - rss.xml</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;rss version="2.0"&gt; &lt;channel&gt; &lt;title&gt;Photo Catalogue Updates&lt;/title&gt; &lt;link&gt;&lt;/link&gt; &lt;description&gt;&lt;/description&gt; &lt;item&gt; &lt;title&gt;Fungus&lt;/title&gt; &lt;link&gt;images/IMG_3036.jpg&lt;/link&gt; &lt;description&gt;A new image has been uploaded&lt;/description&gt; &lt;/item&gt; &lt;/channel&gt; &lt;/rss&gt; </code></pre> <p>Basically I just need to inform the user via RSS that a new image has been added.</p> <p>Thanks</p> <p>UPDATE - Shortened CODE as requested</p> <p>This is the form:</p> <pre><code> &lt;form action="updateaction_rss.php" method="post" enctype="multipart/form-data"&gt; &lt;table&gt; &lt;tr&gt; &lt;td colspan="2"class="labelcell"&gt;&lt;label for="title"&gt;Title:&lt;/label&gt;&lt;/td&gt; &lt;td colspan="2"class="fieldcell"&gt;&lt;input type="text" id="title" name="title" tabindex="2"/&gt;&lt;/td&gt; &lt;/tr&gt; &lt;td colspan="4"&gt;&lt;input type="submit" name="upload" class="box" value="Submit" tabindex="10" /&gt;&lt;/td&gt; &lt;/table&gt; &lt;/fieldset&gt; &lt;/form&gt; </code></pre> <p>This is the code to update the rss file:</p> <pre><code>&lt;?php $record = array( 'title' =&gt; $_POST['title'], ); $rss_doc = new DOMDocument('1.0'); $rss_doc-&gt;formatOutput = true; $rss_doc-&gt;preserveWhiteSpace = false; $rss_doc-&gt;load( "rss.xml" ); $rss_a = $rss_doc-&gt;getElementsByTagName("rss")-&gt;item(0); $rss_b = $rss_doc-&gt;createElement("channel"); $rss_a-&gt;appendChild( $rss_b ); $rss_title = $rss_doc-&gt;createElement("title"); $rss_title-&gt;appendChild( $rss_doc-&gt;createTextNode( $record["title"] ) ); $rss_b-&gt;appendChild( $rss_title ); $rss_doc-&gt;save("rss.xml"); header("Location: {$_SERVER['HTTP_REFERER']}"); ?&gt; </code></pre> <p>Thanks for any advice.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload