PHP generating XML

Discussion in 'Programming/Scripts' started by edge, May 24, 2006.

  1. edge

    edge Active Member Moderator

    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
     
  2. neil6179

    neil6179 New Member

    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
     
  3. edge

    edge Active Member Moderator

    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?
     
  4. sjau

    sjau Local Meanie Moderator

    I'd rather use a .htaccess entry, otherwise every xml is being parsed as PHP...

    The .htaccess could look like this

    Code:
    <Files *xml>
            ForceType application/x-httpd-php
    </Files>
    
     
  5. neil6179

    neil6179 New Member

    Yes, that looks a better solution than mine! :)

    N...
     
    Last edited: May 24, 2006
  6. sjau

    sjau Local Meanie Moderator

    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 ^^
     
  7. edge

    edge Active Member Moderator

    Thanks.. That did the trick :)
     
  8. sjau

    sjau Local Meanie Moderator

    good to hear :)
     

Share This Page