Displaying content from an external XML feed

Last Updated: Feb 14, 2022
documentation for the dotCMS Content Management System

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. Select **Site -> Browser** from the navigation bar 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
  1. You can now preview your page by clicking on the “Preview” tab.

On this page

×

We Dig Feedback

Selected excerpt:

×