Jump to content


Photo

php in other file extensions


  • Please log in to reply
6 replies to this topic

#1 amitrus

amitrus
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 14 July 2006 - 03:14 PM

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? 

#2 shocker-z

shocker-z
  • Members
  • PipPipPip
  • Advanced Member
  • 864 posts
  • LocationNottingham

Posted 14 July 2006 - 03:25 PM

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/p...e-into-xml.html

Regards
Liam
www: www.ukchat.ws | irc: irc.ukchat.ws chan: #blufudge

#3 steelmanronald06

steelmanronald06
  • Staff Alumni
  • Advanced Member
  • 2,004 posts
  • LocationOk

Posted 14 July 2006 - 03:47 PM

go into your apache and add .xml as an extension that php will parse ;)

#4 ShogunWarrior

ShogunWarrior
  • Members
  • PipPipPip
  • Advanced Member
  • 528 posts
  • LocationIreland

Posted 14 July 2006 - 03:52 PM

Just put this in a .htaccess file:
AddType application/x-httpd-php .xml

<a href="http://www.daviddora...nmedia.com/">My New Site/Blog</a> | <a href="http://www.daviddora...m/check/">Check your page for broken links/images/scripts</a>

Zend Certified Engineer
Follow me on Twitter: http://twitter.com/davidd

#5 GingerRobot

GingerRobot
  • Staff Alumni
  • Advanced Member
  • 4,086 posts
  • LocationUK

Posted 14 July 2006 - 03:55 PM

It would be better to do if via apache i think...doesn't .htaccess slow things down?

#6 ShogunWarrior

ShogunWarrior
  • Members
  • PipPipPip
  • Advanced Member
  • 528 posts
  • LocationIreland

Posted 14 July 2006 - 03:58 PM

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.
<a href="http://www.daviddora...nmedia.com/">My New Site/Blog</a> | <a href="http://www.daviddora...m/check/">Check your page for broken links/images/scripts</a>

Zend Certified Engineer
Follow me on Twitter: http://twitter.com/davidd

#7 Koobi

Koobi
  • Staff Alumni
  • Advanced Member
  • 419 posts
  • LocationColombo, Sri Lanka | South Asia

Posted 14 July 2006 - 04:00 PM

.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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users