简体   繁体   中英

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

We have a codeigniter site where basically all the content seen on pages is pulled from xml files. I am not all that familiar with codeigniter so I am having a bit of trouble grasping how to tackle this issue.

For example, the xml file might have this:

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

Ultimately what I would like to do is just make the date wherever it might appear in our content use a php date function, so:

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

Is there anyway I can do this from the XML file or am I approaching in the wrong way?

Do you have control over the XML schema? or at least whatever's generating the XML? You could simply add a special "replace me" type tag to the schema that you can process in codeigniter, essentially making the xml file as sort of template, so you'd have something like

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

If PHP is generating the xml, then just have

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM