Trying to get my RSS Feed from .php to .xml

Discussion in 'Web Design and Development' started by XboxEvolved, Sep 7, 2009.

  1. XboxEvolved macrumors regular

    Aug 22, 2004
    So here is my problem.

    here is my current feed:
    here is the one I am working on.

    What I am trying to accomplish is to get the .xml feed to auto-update every time a new story is posted on the site, something .php one can do already. The reason I would like to replace the .php one is because it is made a little sloppy, has compatilbity problems and I can't use it to autoupdate things such as facebook and twitter pages because it isn't strict xml.

    The .php was done by my old programmer in a matter of a few minutes, the .xml I have been doing myself with a RSS making tool, but I am not sure how to automate it. All the news content is pulled from "section 1" as it reads in the php file. I simply need to figure out a way for it to do the same but on the .xml file. I am pretty sure I need to edit somethign in between <item> </item> tags and that I may need a seperate program or codes running on the site. Would anyone have any insight on how I can do this?
  2. jakeOSX macrumors regular

    Mar 24, 2005
    the automation will be the interesting part.

    one way to do this is to stay with the PHP. you can have the output of a PHP file be formatted like an XML document. The output will be XML, even though the file is a PHP file.

    the only issue with this can be that some XML readers will just dismiss the PHP file since it is PHP.

    you could also have the PHP file write the XML file for you. Then you'll need a way to run the PHP file, cron job or something, so that the XML is updated.
  3. notnek macrumors 6502


    Oct 25, 2007
    i would just set the content type of your PHP file as XML and then print out an XML document.

    header("Content-Type: text/xml");
  4. SrWebDeveloper macrumors 68000


    Dec 7, 2007
    Alexandria, VA, USA

    You might want to look at this excellent XML/RSS writer class written in PHP so you can integrate your content into a feed by writing your own code to pull the latest data as you see fit, then initiate the class and pass that data to it and use it to generate the actual feed.

    The guy who wrote that class also wrote RSS reader classes with caching mechanisms if you opt to run this script outside of cron. Awesome stuff for a customized solution.


Share This Page