Best way to create dynamic xml?

Status
Not open for further replies.

Breakpoint

New member
Oct 7, 2006
316
4
0
I am not to knowledgable in programming for xml so I wanted to find the best answer.

I was curious what is the best way to create a dynamic xml file.

The only way I have done it so far is creating a .php file that echos out xml messages containing content from my database. And then creating a .htaccess file that turns the .php file into an .xml file. I did this method when I created my RSS Feed.

Is there a better way to do this?
 


*shrugs* You're pretty much doing it right.
There are PHP helper classes to generate XML, etc, and you don't "have" to use the .htaccess trick to make it a .xml (a .php file with an XML MIME type and XML headers is usually fine), but if you're trying to go SQL->XML, going through PHP is probably your best bet.
 
  • Like
Reactions: Breakpoint
Does the MIME type change the file name tho?

I'm looking for changing filename.php to filename.xml, I don't think a MIME type would do that, or am I wrong? The htaccess changes the name tho.
 
in this-file-generates-xml.php:
<?php
header
("content-type: text/xml");
echo '<?xml version="1.0" encoding="UTF-8"?>';
echo $my_xml;
?>

If you really want the file extension to be XML, the htaccess trick is correct. However, this is unnecessary, and you can parse the XML regardless of the file extension.
 
Status
Not open for further replies.