How to import RSS newsfeeds as articles?
The following example describes how to import data from XML or RSS feeds or files and display those as an articles in one of your site's sections. We use the following Wired RSS format news feed in our sample: http://www.wired.com/news/feeds/rss2/0,2610,,00.xml.Step one: define data mapping
Data mapping defines which data field from the XML format is imported into which CMS database field. Alternatively we can import data into the CMS article object, which we do in our example.
If you investigate the RSS data format from the link above, you will find out, that the articles are surrounded by the <item> tag. Inside the <item>, we have <title>, <link> and <description> which pay interest to us. Now:
- Go to your site Administrator's envirovment and find Integration > XML data mapping.
- Click New to create new data mapping and enter name, for example "Wired news".
- Click New to create new field pair. A popup window will open.
- From "Section" dropdown, select the section into which you wish to import the data.
- From "Database field" dropdown, choose appropriate article field, like "title".
- Into "XML element" field, type the name of the field in the XML format (omit the "<" and ">"): title.
- Repeat steps 3 to 6 with the "link" and "description" fields.
Step 2: define the data source
- Go to your site Administrator's envirovment and find Integration > XML directories.
- Click New and choose "Import", "Using CMS".
- Into "XML files directory / URL" enter the data source: http://www.wired.com/news/feeds/rss2/0,2610,,00.xml.
- Choose "Wired news" from "Data mapping" dropdown.
- Into "Start from element" enter "/rss/channel/item". This defines where to look for the fields described in the data mapping, from the XML stucture.
- Click on "Active" radiobutton to enable this import.
Step 3: run import
Click "Run now" to run the import and display possbile errors. The import runs on every hour during the page display in the public site. Alternatively you can run the import from system cron.
RSS