如何从xml文件生成php动态日期


How do I generate a php dynamic date from an xml file?

我们有一个codeigniter站点,基本上页面上看到的所有内容都是从xml文件中提取的。我对codeigniter不是很熟悉,所以我在理解如何解决这个问题时遇到了一些困难。

例如,xml文件可能包含以下内容:

<view>home</view>
    <meta>
        <keywords>blue widgets, green widgets, red widgets</keywords>
        <description>We have the best widgets for 2012</description>
    </meta>

最终,我想做的只是使用php日期函数使日期出现在我们内容中的任何位置,因此:

<view>home</view>
    <meta>
        <keywords>blue widgets, green widgets, red widgets</keywords>
        <description>We have the best widgets for {somehow put php date here}</description>
</meta>

我是否可以从XML文件中做到这一点,或者我是否以错误的方式接近?

您可以控制XML模式吗?或者至少是生成XML的东西?您可以简单地将一个特殊的"替换我"类型标记添加到模式中,您可以在codeigniter中处理该模式,本质上是将xml文件作为某种模板,这样您就有了类似的东西

<description>We have the best widgets for <dategoeshere /></description>

如果PHP正在生成xml,那么只需使用

<description>We have the best widgets for <?php echo date('Y') ?></description>