creating XML with embedded PHP

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Troy

    creating XML with embedded PHP

    Hi-

    I am attempting to set up an RSS feed using PHP. It would be convenient for
    me to embed PHP into an xml file like I would do to an HTML file in order to
    create the XML, however the apache server does not realize that it's PHP
    content and the PHP engine is not run against that code. so I have to call
    it feed.php instead of feed.xml, and most of the rss readers don't
    appreciate this.

    My alternative is to create the XML file every day or so (using PHP or
    whatever), however that does not guarantee that the person requesting the
    rss feed gets up to date info.

    I would really like to know if there is a way to create the XML file on the
    fly using PHP without modifying the apache server.

    Thanks,
    troy


  • Andy Hassall

    #2
    Re: creating XML with embedded PHP

    On Mon, 05 Jan 2004 21:54:49 GMT, "Troy" <troy@morpheus. No_SpAm.net> wrote:
    [color=blue]
    >I am attempting to set up an RSS feed using PHP. It would be convenient for
    >me to embed PHP into an xml file like I would do to an HTML file in order to
    >create the XML, however the apache server does not realize that it's PHP
    >content and the PHP engine is not run against that code. so I have to call
    >it feed.php instead of feed.xml, and most of the rss readers don't
    >appreciate this.[/color]

    They _shouldn't_ care so long as you send the appropriate Content-type header
    (Content-type: application/xml , I think).
    [color=blue]
    >My alternative is to create the XML file every day or so (using PHP or
    >whatever), however that does not guarantee that the person requesting the
    >rss feed gets up to date info.
    >
    >I would really like to know if there is a way to create the XML file on the
    >fly using PHP without modifying the apache server.[/color]

    Depends whether you count this as "modifying" the server, but a ForceType
    directive in a .htaccess file might do the trick:



    <Files "feed.xml">
    ForceType application/x-httpd-php
    </files>

    --
    Andy Hassall (andy@andyh.co. uk) icq(5747695) (http://www.andyh.co.uk)
    Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)

    Comment

    • Chung Leong

      #3
      Re: creating XML with embedded PHP

      Try putting a dummy .xml filename into the url.



      When Apache fails to find the file /.../feed.php/feed.xml, it'll run
      /.../feed.php instead.

      Setting the content-type header should work though. And depending on how
      popular the feed is, generating a static version of the file isn't a bad
      idea. You would update the file whenever you add a new story. Since that
      should happen less often then retrieval of the feed, it's more efficient.

      Uzytkownik "Troy" <troy@morpheus. No_SpAm.net> napisal w wiadomosci
      news:J2lKb.9$w5 .121822330@news svr30.news.prod igy.com...[color=blue]
      > Hi-
      >
      > I am attempting to set up an RSS feed using PHP. It would be convenient[/color]
      for[color=blue]
      > me to embed PHP into an xml file like I would do to an HTML file in order[/color]
      to[color=blue]
      > create the XML, however the apache server does not realize that it's PHP
      > content and the PHP engine is not run against that code. so I have to[/color]
      call[color=blue]
      > it feed.php instead of feed.xml, and most of the rss readers don't
      > appreciate this.
      >
      > My alternative is to create the XML file every day or so (using PHP or
      > whatever), however that does not guarantee that the person requesting the
      > rss feed gets up to date info.
      >
      > I would really like to know if there is a way to create the XML file on[/color]
      the[color=blue]
      > fly using PHP without modifying the apache server.
      >
      > Thanks,
      > troy
      >
      >[/color]


      Comment

      • Remon Huijts

        #4
        Re: creating XML with embedded PHP

        "Troy" <troy@morpheus. No_SpAm.net> schreef in bericht
        news:J2lKb.9$w5 .121822330@news svr30.news.prod igy.com...[color=blue]
        > I am attempting to set up an RSS feed using PHP. It would be convenient[/color]
        for[color=blue]
        > me to embed PHP into an xml file like I would do to an HTML file in order[/color]
        to[color=blue]
        > create the XML, however the apache server does not realize that it's PHP
        > content and the PHP engine is not run against that code. so I have to[/color]
        call[color=blue]
        > it feed.php instead of feed.xml, and most of the rss readers don't
        > appreciate this.[/color]

        Is it an idea to keep the script named feed.php, but make the url point to
        feed.php?ext=.x ml
        The script would of course do nothing with the extra variable that is
        created with this method, but it might satisfy the RSS readers. I really
        wouldn't know, cuz I know nothing about RSS at all, but it was just an idea
        not including server modifications.

        Remon.


        Comment

        • Manuel Lemos

          #5
          Re: creating XML with embedded PHP

          Hello,

          On 01/05/2004 07:54 PM, Troy wrote:[color=blue]
          > I am attempting to set up an RSS feed using PHP. It would be convenient for
          > me to embed PHP into an xml file like I would do to an HTML file in order to
          > create the XML, however the apache server does not realize that it's PHP
          > content and the PHP engine is not run against that code. so I have to call
          > it feed.php instead of feed.xml, and most of the rss readers don't
          > appreciate this.
          >
          > My alternative is to create the XML file every day or so (using PHP or
          > whatever), however that does not guarantee that the person requesting the
          > rss feed gets up to date info.
          >
          > I would really like to know if there is a way to create the XML file on the
          > fly using PHP without modifying the apache server.[/color]

          You may want to try these classes to generate a XML RSS feed:





          --

          Regards,
          Manuel Lemos

          Free ready to use OOP components written in PHP
          Free PHP Classes and Objects 2025 Versions with PHP Example Scripts, PHP Tutorials, Download PHP Scripts, PHP articles, Remote PHP Jobs, Hire PHP Developers, PHP Book Reviews, PHP Language OOP Materials


          Comment

          • Troy

            #6
            Re: creating XML with embedded PHP

            Chung suggested this and I agree that it makes a lot of sence to update the
            XML file only after submission of new stuff.
            [color=blue]
            >And depending on how popular the feed is,
            >generating a static version of the file isn't a bad
            >idea. You would update the file whenever you
            >add a new story. Since that should happen
            >less often then retrieval of the feed, it's more efficient.[/color]

            This works, except in order to create the file in public_html/rss I need to
            alter the permissions on feed.xml to 666 since my the webserver user had no
            permission to write in my personal user directory. I don't want to leave it
            with 666 perms, so is there another way to do this, or should I let the
            webserver user own that file?

            Thanks!
            troy


            Comment

            • Chung Leong

              #7
              Re: creating XML with embedded PHP

              The answer is nope, unless your're the server administrator.

              Uzytkownik "Troy" <troy@morpheus. No_SpAm.net> napisal w wiadomosci
              news:TlEKb.12$R c1.122076171@ne wssvr30.news.pr odigy.com...[color=blue]
              > Chung suggested this and I agree that it makes a lot of sence to update[/color]
              the[color=blue]
              > XML file only after submission of new stuff.
              >[color=green]
              > >And depending on how popular the feed is,
              > >generating a static version of the file isn't a bad
              > >idea. You would update the file whenever you
              > >add a new story. Since that should happen
              > >less often then retrieval of the feed, it's more efficient.[/color]
              >
              > This works, except in order to create the file in public_html/rss I need[/color]
              to[color=blue]
              > alter the permissions on feed.xml to 666 since my the webserver user had[/color]
              no[color=blue]
              > permission to write in my personal user directory. I don't want to leave[/color]
              it[color=blue]
              > with 666 perms, so is there another way to do this, or should I let the
              > webserver user own that file?
              >
              > Thanks!
              > troy
              >
              >[/color]


              Comment

              Working...