Read and process RSS feed using Embed and XmlProcessor
The feedreader macro, in the Web Toolkit, allows you to read RSS and convert its data to a DataTable, which can then be formatted. It is however possible to read the xml yourself and pass it to a transform macro, or use the XmlProcessor (new in 1.3).
Here's an example of XmlProcessor processing a feed:
Smartsite SXML | Copy Code |
---|---|
<se:cache maxage="00:20" save="key = this.getcachekey()" resulttype="none" whitespace="remove"> <se:embeduri resulttype="xml" location="http://rss.cnn.com/rss/edition.rss" /> </se:cache> <se:xmlprocessor xmldata="{cache.get(buffer.get(key))}" buildstring="true"> <se:parameters> <se:parameter name="resultformat"> <ul>{this.result()}</ul> </se:parameter> <se:parameter name="actions"> <se:collection> <se:member query="//channel/item" type="multiplenodes"> <li><a href="{this.getvalue(link)}">{this.getvalue(title)}</a></li> </se:member> </se:collection> </se:parameter> </se:parameters> </se:xmlprocessor> |
Example Result | Copy Code |
---|---|
<ul> <li><a href="http://edition.cnn.com/2011/WORLD/meast/01/19/iraq.violence/index.html?eref=edition">Suicide bombers target Iraqi security forces</a></li> <li><a href="http://edition.cnn.com/2011/WORLD/africa/01/19/tunisia.protests/index.html?eref=edition">Tunisian protesters return to streets</a></li> <li><a href="http://edition.cnn.com/2011/WORLD/africa/01/19/ivory.coast.crisis/index.html?eref=edition">Envoy blames Gbagbo for Ivorian crisis</a></li> <li><a href="http://edition.cnn.com/2011/WORLD/americas/01/18/haiti.duvalier/index.html?eref=edition">Charges filed against 'Baby Doc' Duvalier</a></li> <li><a href="http://edition.cnn.com/2011/POLITICS/01/19/china.us.visit/index.html?eref=edition">White House dinner for China's Hu</a></li> <li><a href="http://edition.cnn.com/2011/WORLD/americas/01/18/brazil.flooding/index.html?eref=edition">Brazil flood death toll passes 700</a></li> <li><a href="http://edition.cnn.com/2011/WORLD/americas/01/19/bolivia.coca.campaign/index.html?eref=edition">Bolivia seeks buzz with coca campaign</a></li> <li><a href="http://edition.cnn.com/2011/WORLD/asiapcf/01/19/australia.floods/index.html?eref=edition">Australian flooding 'whacks' economy</a></li> <li><a href="http://edition.cnn.com/2011/WORLD/asiapcf/01/18/pakistan.quake/index.html?eref=edition">Major earthquake strikes Pakistan</a></li> <li><a href="http://edition.cnn.com/2011/CRIME/01/19/ireland.death/index.html?eref=edition">New court hearing on honeymoon death</a></li> </ul> |