Server side - pulling and displaying an XML / RSS feed
Reading an XML
or an RSS
feed and displaying the content is simple. This example uses the $xmltool
in velocity to pull a news feed and display its contents. In a real world example, you would probably want to cache the results.
#set($myXML = $xmltool.read("https://techxplore.com/rss-feed/"))
#foreach($childEntry in $myXML.children.iterator)
#set($entryXML = $xmltool.parse($childEntry))
<p>
Title: $entryXML.title.text <br />
Link: $entryXML.link.text <br />
Category: $entryXML.category.text <br />
PubDate: $entryXML.pubDate.text <br />
description: $entryXML.description.text <br />
</p>
#end