RSS to XML file? How?

by 9 replies
11
I need to create a XML file, using the RSS feed.

Trouble is, is that I have NO idea where to even start.

Anyone comfortable with this please PM me to find out more.....
#programming #file #rss #xml
  • Google simple xml - you'll find some examples and it's available by default with php 5+
  • You'll need to give more info. Its unclear whether you want to do this for _your_ RSS feed from your server and so have direct access to the data coming from the database or whether it is someone elses RSS feed that you want to transform into XML structure to do something with it.

    If its the second, what is the form of the incoming RSS feed and what does the structure of the XML need to look like.
    • [1] reply
    • The RSS is external, from Amazon, eg. Amazon's Bestsellers. The need is to make an XML file with the data fields re-ordered to a format containing following lines:
      <?xml version="1.0" encoding="utf-8"?>
      <list>
      <list image="item1 image URL" action="URL of item on Amazon site" target="_new"
      title="item title" desc="item description (limit 200 characters"/>
      <list image="item2 image URL" action="URL of item on Amazon site" target="_new"
      title="item title" desc="item description (limit 200 characters"/>
      .etc...... repeated 20 times

      </list>


      How does one know what is coming down the feed on any RSS, if these are external feeds?
      • [1] reply
  • If it was me, I would look at the structure it came down in for any structural formats that I could use, then write a script in php to re-format those structures into the format I wanted.

    Look for things like <div class="the_image"><img.........></div> then use a regular expression to match that and get the contents to output to XML.

    Someone else might have a trick to it that already has been built since it a big one like an amazon feed though.
  • RSS is XML. XML is simply extensible markup language. RSS is a defined set of tags in XML format.
  • OK, for the "looking part", are there any "tools" that will allow me to look at the raw feed so I know what is in the stream, and know what kind of data (fields???) exists ?

    Like some sort of "peeper" (for want of a better word)???
    • [1] reply
    • To get a copy of the XML file an RSS feed will return to your PHP file just create a new php file with the following code on it:

      Code:
      <?php
      $contents = file_get_contents("http://www.your_feed_url_goes_here.com/");
      echo "<textarea rows="50" cols="100">".$contents."</textarea>";
      ?>
      When you load the new php page on a browser you will get a textbox with the RSS code inside of it.

      Hope that helps.
      • [ 1 ] Thanks
      • [1] reply

Next Topics on Trending Feed