PDA

View Full Version : PHP generating XML


edge
24th May 2006, 15:38
Hi all,

I've got this small PHP script that will generate a XML output from a MySQL.
When I call the 'make.php' file it does show a nice XML output.

How do I get this script to listen to a .XML request instead of a .PHP one?
Do I need to add something in my .htaccess file?

example:
mydomain.tld/make.php does work and generate a xml output from my MySQL on screen.
mydomain.tld/make.xml does not work (as there is no .xml file)

System I'm trying this on is CentOS using PHP 4.3.10

neil6179
24th May 2006, 15:52
Hi,

I'm afraid I've not done this on CentOS using PHP 4.3.10, but on SuSE with Apache 2 you'd just need to add the following line into Apaches PHP config file (/etc/apache2/conf.d/php5.conf):

AddType application/x-httpd-php .xml

Apache will then just treat all files with the .xml extention as a PHP script.

Hope this helps...

Neil

edge
24th May 2006, 17:48
Hi,

I'm afraid I've not done this on CentOS using PHP 4.3.10, but on SuSE with Apache 2 you'd just need to add the following line into Apaches PHP config file (/etc/apache2/conf.d/php5.conf):

AddType application/x-httpd-php .xml

Apache will then just treat all files with the .xml extention as a PHP script.

Hope this helps...

Neil

Hello Neil,

I do have a AddType application/x-httpd-php .php in my php.ini file.
Can I (if it works) just add .xml after the .php, or do I need to make a new linke?

AddType application/x-httpd-php .php .xml or a new line with only AddType application/x-httpd-php .xml

I guess I will also need to restart Apache after this?

sjau
24th May 2006, 18:14
I'd rather use a .htaccess entry, otherwise every xml is being parsed as PHP...

The .htaccess could look like this


<Files *xml>
ForceType application/x-httpd-php
</Files>

neil6179
24th May 2006, 18:17
Yes, that looks a better solution than mine! :)

N...

sjau
24th May 2006, 18:20
Neil, you're solution definitively works... I'm not 100% sure about how to specify the files... I think *xml is ok but as said, not 100% sure ^^

edge
24th May 2006, 18:37
I'd rather use a .htaccess entry, otherwise every xml is being parsed as PHP...

The .htaccess could look like this


<Files *xml>
ForceType application/x-httpd-php
</Files>


Thanks.. That did the trick :-)

sjau
24th May 2006, 20:25
good to hear :)