我有一个HTML表单,当提交后会将值post到一个PHP文件中。这些值将被读入XMLWriter中,代码如下:
这个系统整体运作良好。它根据表单按照我需要的方式创建XML。但我无法弄清楚如何使它在每次提交表单时都添加一个新项到XML中,而不是覆盖相同的条目。
谢谢。
<?php
$pastor= $_POST["Speaker"];
$title= $_POST["Title"];
$link= $_POST["podcasturl"];
$download= $_POST["Download"];
$podcastid= $_POST["Podcastid"];
$pubdate= $_POST ["Date"];
$xml = new XmlWriter();
$xml->openURI('podcast.xml');
$xml->formatOutput = true;
$xml->startDocument('1.0');
$xml->setIndent(4);
$xml->startElement("podcast");
$xml->writeElement('pastor', $pastor);
$xml->writeElement('title', $title);
$xml->writeElement('link', $link);
$xml->writeElement('download', $download);
$xml->writeElement('podcastid', $podcastid);
$xml->writeElement('pubdate', $pubdate);
$xml->endElement();
$xml->endElement();
$xml->endDocument();
?>
这个系统整体运作良好。它根据表单按照我需要的方式创建XML。但我无法弄清楚如何使它在每次提交表单时都添加一个新项到XML中,而不是覆盖相同的条目。
谢谢。