I have just started using XML as I usually use php but I am trying to create a RSS feed so it is necesary. What is the best way of getting the data from my mysql database which I use with php that stores my blog? Is there anyway of using php inside of a XML document or would I have to do it using XML?
1 Answer
You are confused. XML is a format to store data, like .doc, .txt or .bmp (for image data).
If you want to get data from MySQL and put it in XML, you'll need a program that will do this for you.
You can use PHP to read the data from MySQL, and output it as XML or RSS.
6 Comments
Yesterday
I see, is there a tutorial on how to do this? I must have got confused because you use tags in it like html.
Konerak
There are thousands, a quick google showed me kirupa.com/web/mysql_xml_php.htm or techrepublic.com/article/create-xml-with-mysql-and-php/5035149 ?
Eli
If you are working with a Linux server, you can always use @konerak answer to create a php script to pull the data from the MySQL database and output it to XML/RSS. After you have created the script you can configure a cron job to run the script every so often (like once an hour or whatever) to pull new MySQL data.
0 */1 * * * root php /scripts/update_RSS.phpYesterday
so I can set a rss feed as a php file?
Lightness Races in Orbit
@Yesterday: You don't do this in HTML any more than in XML! You've made the mistake of thinking that PHP goes "in" HTML, whereas in fact PHP is often seen outputting HTML.
|