Is it possible to code inside XML file for an RSS Feed?

Please support our RSS, Web Services and SOAP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Reply

Join Date: May 2007
Posts: 66
Reputation: dudegio is an unknown quantity at this point 
Solved Threads: 0
dudegio dudegio is offline Offline
Junior Poster in Training

Is it possible to code inside XML file for an RSS Feed?

 
0
  #1
Jun 18th, 2009
Hello guys,

I need an expert advice if it is possible to code inside an XML file? Example, news.xml whereas in that file you have to code connecting to MySQL database then retrieve data. Generated data is the XML required tags for the RSS and will be written in similar file that is the news.xml.

All I know is, an XML file only contains XML tags and no coding. Any idea please share. Thank you very much.

GIO
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 789
Reputation: pritaeas is on a distinguished road 
Solved Threads: 127
Sponsor
pritaeas's Avatar
pritaeas pritaeas is offline Offline
Master Poster

Re: Is it possible to code inside XML file for an RSS Feed?

 
0
  #2
Jun 18th, 2009
Not possible from within an XML file. However, you could for example use a .htaccess file to redirect news.xml to a php file which will generate and output the XML.
"If it is NOT source, it is NOT software."
-- NASA
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 66
Reputation: dudegio is an unknown quantity at this point 
Solved Threads: 0
dudegio dudegio is offline Offline
Junior Poster in Training

Re: Is it possible to code inside XML file for an RSS Feed?

 
0
  #3
Jun 18th, 2009
Originally Posted by pritaeas View Post
Not possible from within an XML file. However, you could for example use a .htaccess file to redirect news.xml to a php file which will generate and output the XML.
Hi Can you teach me how please? thank you.
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 789
Reputation: pritaeas is on a distinguished road 
Solved Threads: 127
Sponsor
pritaeas's Avatar
pritaeas pritaeas is offline Offline
Master Poster

Re: Is it possible to code inside XML file for an RSS Feed?

 
0
  #4
Jun 25th, 2009
Hi. You can use this in your htaccess file

RSS, Web Services and SOAP Syntax (Toggle Plain Text)
  1. RewriteRule ^news.xml$ "news.php" [L]

It redirects news.xml to news.php.

In news.php you can use:

  1. header("Content-Type: application/xml; charset=ISO-8859-1");

to state that your output will be xml. After this, just output your generated tags.

Sorry for the late reply, I've been away.
"If it is NOT source, it is NOT software."
-- NASA
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 797
Reputation: Airshow is on a distinguished road 
Solved Threads: 112
Airshow's Avatar
Airshow Airshow is offline Offline
Master Poster

Re: Is it possible to code inside XML file for an RSS Feed?

 
0
  #5
Jul 2nd, 2009
Hi,

Pritaeas solution is neat but does rely on Apache MOD_REWRITE being enabled, which is not always the case.

Another way to do it is to request the worker page (eg. news.php) directly and specify any content criteria in the query part of the url.

For example
http://www.blah.domain/feeds/news.php?s=fashion&d=5&c=france

The values s, d, c would be entirely of your own choosing (I just invented these ones) and would be interpreted server-side from $_GET in PHP (or ASP, JSP etc) to compose corresponding SQL, perform the database lookup, and finally compose and serve the output XML (or HTML or whatever is your final product).

Some RSS feeds are served this way, eg,
http://www.blog.nl/rss.php?blogId=17&profile=rss20
http://www.stern.de/standard/rss.php?channel=sport-motor

though it is more common to find path-mapped urls eg.;
http://www.pheedo.com/f/newscientist_motoring-tech

Airshow
50% of the solution lies in accurately describing the problem!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the RSS, Web Services and SOAP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC