从另一个 XML 文件更新 RSS 文件


Update RSS file from another XML file

我不知道该怎么做?

我希望能够更新一个 xml 文件(我可以这样做),然后从这个 xml 文件原子地更新 rss 提要。希望这是有道理的。

我可以更新和显示 XML 文件中的数据。我用XSL和一些PHP来做到这一点。

我可以从 RSS 文件创建和显示数据。

我不知道如何链接两者,因此当我更新XML文件时,它会更新RSS文件中的详细信息。

希望这是有道理的。

这是 xml 文件 - 目录.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>

这是 RSS 文件 - 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>

基本上,我只需要通过RSS通知用户已添加新图像。

谢谢

更新 - 根据要求缩短代码

这是形式:

  <form action="updateaction_rss.php" method="post" enctype="multipart/form-data">
 <table>
    <tr>  
     <td colspan="2"class="labelcell"><label for="title">Title:</label></td>
     <td colspan="2"class="fieldcell"><input type="text" id="title" name="title"  tabindex="2"/></td>
   </tr>
   <td colspan="4"><input type="submit" name="upload" class="box" value="Submit" tabindex="10" /></td>
  </table>
</fieldset>
  </form>

这是更新 rss 文件的代码:

<?php
$record = array(
    'title' => $_POST['title'],
 );

$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_a->appendChild( $rss_b );

$rss_title = $rss_doc->createElement("title");
$rss_title->appendChild(
    $rss_doc->createTextNode( $record["title"] )
);
$rss_b->appendChild( $rss_title );

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

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

感谢您的任何建议。

好的 -

想通了 - 我的错 - 我没有给 rss.xml 文件正确的读/写权限。对不起,我想这是一个很好的学习经历!