Displaying content from an external Atom feed - Documentation topics on: atom,feeds,howto,pull rss feed,rss,rss feeds,velocity tools,xmltool,xml tool,.

Displaying content from an external Atom feed

The Atom Syndication Format is an XML language used for web feeds. Here's an example of how to take an external Atom Feed and display the content in a dotCMS HTML Page using the XmlTool in a widget

  1. Click on the Site Browser tab and select a folder, then right click on it and click on: New --> HTML Page. 
  2. In the Add/Edit HTML Page screen enter the following information and click on Save.
  3. In Edit Mode, click on a Body Container: Add Content button and select "Add Widget". 
  4. A dialog box will display, select the widget type: Simple Widget on the left column and then click on "Create New Simple Widget".
  5. In the "Add/Edit Simple Widget" screen, enter the title: Display Content from External Atom Feed. In the code field use the following code and click on Save.
    #set($myXML = $xmltool.read("http://demo.dotcms.com/home/atom-feed.html"))
    #foreach($childEntry in $myXML.children().iterator())
      #set($entryXML = $xmltool.parse($childEntry))  
          <p>
          Title: $entryXML.title.text <br />
          Link:  $entryXML.link.text <br />
          Id:  $entryXML.id.text <br />
          Updated:  $entryXML.updated.text <br />
          Summary:  $entryXML.summary.text <br />
          </p>
    #end
    
  6. You can now preview your page by clicking on the "Preview" tab.