943,822 Members | Top Members by Rank

Jun 18th, 2009
0

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

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
dudegio is offline Offline
66 posts
since May 2007
Jun 18th, 2009
0

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

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.
Sponsor
Featured Poster
Reputation Points: 550
Solved Threads: 729
Bite my shiny metal ass!
pritaeas is offline Offline
4,176 posts
since Jul 2006
Jun 18th, 2009
0

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

Click to Expand / Collapse  Quote originally posted by pritaeas ...
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.
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
dudegio is offline Offline
66 posts
since May 2007
Jun 25th, 2009
0

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

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:

php Syntax (Toggle Plain Text)
  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.
Sponsor
Featured Poster
Reputation Points: 550
Solved Threads: 729
Bite my shiny metal ass!
pritaeas is offline Offline
4,176 posts
since Jul 2006
Jul 2nd, 2009
0

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

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
Sponsor
Reputation Points: 318
Solved Threads: 358
WiFi Lounge Lizard
Airshow is offline Offline
2,526 posts
since Apr 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in RSS, Web Services and SOAP Forum Timeline: Need help on restful web service
Next Thread in RSS, Web Services and SOAP Forum Timeline: RSS feeds to PDF





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC