ojsimon Posted November 22, 2008 Share Posted November 22, 2008 Hi I am trying to create an xml file like this <?xml version="1.0" encoding="UTF-8" ?> <Module> <ModulePrefs title="hello world example" /> <Content type="html"> <![CDATA[ Hello, world! ]]> </Content> </Module> Insteas of the <![CDATA[ Hello, world! ]]> I would like to insert dynamic code. AS i am trying to allow my users to embed dynamic widgets to igoogle. How can i replace this hello world code with dynamically placed code. Any suggestions Quote Link to comment https://forums.phpfreaks.com/topic/133765-dynamically-generate-xml/ Share on other sites More sharing options...
Mchl Posted November 22, 2008 Share Posted November 22, 2008 <?xml version="1.0" encoding="UTF-8" ?> <Module> <ModulePrefs title="hello world example" /> <Content type="html"> <![CDATA[ <?php //here put script to generate your data ?> ]]> </Content> </Module> Quote Link to comment https://forums.phpfreaks.com/topic/133765-dynamically-generate-xml/#findComment-696126 Share on other sites More sharing options...
ojsimon Posted November 22, 2008 Author Share Posted November 22, 2008 Yeh but this will not run in a .xml file and the xml will not run iN A php Quote Link to comment https://forums.phpfreaks.com/topic/133765-dynamically-generate-xml/#findComment-696127 Share on other sites More sharing options...
Mchl Posted November 22, 2008 Share Posted November 22, 2008 Use mod_rewrite to rewrite yourfile.xml.php to yourfile.xml Quote Link to comment https://forums.phpfreaks.com/topic/133765-dynamically-generate-xml/#findComment-696129 Share on other sites More sharing options...
ojsimon Posted November 22, 2008 Author Share Posted November 22, 2008 How do i write an htaccess file to do that? Quote Link to comment https://forums.phpfreaks.com/topic/133765-dynamically-generate-xml/#findComment-696130 Share on other sites More sharing options...
DarkerAngel Posted November 22, 2008 Share Posted November 22, 2008 Options +FollowSymlinks RewriteEngine on RewriteBase / RewriteRule ^yourfile.xml$ /yourfile.xml.php [nc] Save as .htaccess Quote Link to comment https://forums.phpfreaks.com/topic/133765-dynamically-generate-xml/#findComment-696136 Share on other sites More sharing options...
ojsimon Posted November 22, 2008 Author Share Posted November 22, 2008 Sill not working? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/133765-dynamically-generate-xml/#findComment-696149 Share on other sites More sharing options...
Mchl Posted November 22, 2008 Share Posted November 22, 2008 I have this one working for my site. RewriteEngine on RewriteBase / RewriteRule ^news\.xml$ news.xml.php It seems that . (dot) has to be escaped (\.). Quote Link to comment https://forums.phpfreaks.com/topic/133765-dynamically-generate-xml/#findComment-696168 Share on other sites More sharing options...
ojsimon Posted November 23, 2008 Author Share Posted November 23, 2008 still the .xml file is not running the php. It just returns the php code without it being processed in the server. any other advice? thanks Quote Link to comment https://forums.phpfreaks.com/topic/133765-dynamically-generate-xml/#findComment-696903 Share on other sites More sharing options...
Mchl Posted November 23, 2008 Share Posted November 23, 2008 I wonder... maybe that's because code is inside CDATA section... Quote Link to comment https://forums.phpfreaks.com/topic/133765-dynamically-generate-xml/#findComment-696906 Share on other sites More sharing options...
curt22 Posted November 23, 2008 Share Posted November 23, 2008 Hi osjimon, Did you make sure the file was named .htaccess? Also some hosts don't allow you to write .htaccess files so you might want to check that. I was able to get this working using this file: RewriteEngine on RewriteBase / RewriteRule ^test\.xml$ test.xml.php Hope some of that helped. Quote Link to comment https://forums.phpfreaks.com/topic/133765-dynamically-generate-xml/#findComment-697080 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.