Jump to content

Archived

This topic is now archived and is closed to further replies.

amitrus

php in other file extensions

Recommended Posts

I am currently trying to include php code in a .xml file.  The file would look something like this

<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title></title>
<link></link>
<description></description>
<language>en-us</language>
<copyright></copyright>
<item>
<title></title>
<description> <?php echo $value; ?>  </description>
</item>
</channel>
</rss>


But I need to get my server to see the php in the .xml file. (The extension has to be .xml) How can I do this?  I've been fooling around with the .htaccess file, but still can't make my server see the php in a .xml file (I did manage, however, to make it see the php in a .html file by changing the .htaccess file.). 

Can anyone help me? 

Share this post


Link to post
Share on other sites
I think you have to have a PHP file but then give the file a header of an xml file..

Maby this site is some help?

http://www.xml.com/pub/a/2003/03/19/dive-into-xml.html

Regards
Liam

Share this post


Link to post
Share on other sites
It would be better to do if via apache i think...doesn't .htaccess slow things down?

Share this post


Link to post
Share on other sites
Well in the Apache config then, I didn't have a choice in my hosting environment because i didn't have access to apache config, but whatever suits.

Share this post


Link to post
Share on other sites
.htaccess is a part of Apache.
you don't need to access any apache configs. just add what ShogunWarrior posted in an .htaccess file and save that .htaccess file to the working directory.


but your XML file isn't valid to begin with.
you would have to surround your XML in CDATA tags

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.