EJEMPLO 1 BBCk hainbat RRS eskaintzen ditu, adib. UK Educational news
let $news := doc("http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/education/rss.xml") let $dateTime := $news/rss/channel/lastBuildDate return <html> <body> <h2>Noticias nuevas de la BBC{string($dateTime)}</h2> { for $newsItem in $news/rss/channel/item[position() < 10] return <div> <h4>{string($newsItem/title)}</h4> <p>{string($newsItem/title/description)} <a href="{$newsItem/link}">Ver mas..</a></p> </div> } </body></html>
EJEMPLO 2 Leer varios RSS
Utilizando funciones
declare function local:linea($link, $titulua)
{
<div>
RSS itema <b> {$titulua}</b><br/>
<a href="{$link}"> Enlace</a>
<hr/>
</div>
};
declare function local:filter-rss($url)
{
for $b in doc($url)/rss/channel/item
return local:linea($b/link/text(), $b/title/text())
};
<html>
<body>
<i>Lector de RSS por Xquery.</i>
<hr/>
{local:filter-rss("http://www.badok.eus/feed/")}
{local:filter-rss("http://www.eitb.eus/eu/rss/kultura/musika/")}
{local:filter-rss("http://www.naiz.eus/eu/rss/news.rss")}
{local:filter-rss("http://www.music-news.com/rss/UK/news?includeCover=true")}
</body>
</html>
Ejemplo 3 Utilizando tabla
declare function local:linea($link, $titulua)
{
<div>
RSS item <b> {$titulua}</b><br/><b>{$link}</b>
<hr/>
</div>
};
declare function local:filter-rss($url)
{
for $b in doc($url)/rss/channel/item
return local:lerroa($b/link/text(), $b/title/text())
};
<html>
<body>
<h1>Lector de RSS con XQuery</h1>
<table border="2">
<tr>
<td>
{local:filter-rss("http://www.naiz.eus/eu/rss/news.rss")}
</td>
</tr>
</table>
<table border="2">
<tr>
<td>
{local:filter-rss("http://www.music-news.com/rss/UK/news?includeCover=true")}
</td>
</tr>
</table>
</body>
</html>
EJEMPLO 4
The script reads the RSS-feed at Slashdot.org and formats it as a list and displays the title as a link to the source. Explanation: the XQuery statement below reads the RSS-feed from file slashdot.org and displays all the items it finds. slashdot.xq: <html><body> <h1>Slashdot.org News</h1> <ul> { for $t in doc("http://www.naiz.eus/eu/rss/news.rss")//*:item return element li { element a { attribute href { $t/*:link/text() }, text { $t/*:title } } } } </ul> </body> </html>
EJEMPLO 5
(: get a list of titles form the Art and Design RSS feed of the New York Times :)
<html>
<head>
<tytle>Art and Design</tytle>
</head>
<body>
<h1>List of titles form the Art and Design</h1>
<ul>{
(: make a list of the items and create links :)
for $item in doc("http://www.nytimes.com/services/xml/rss/nyt/ArtandDesign.xml")//item
return
<li>
<a href="{fn:string($item/link)}">{fn:string($item/title)}</a>
</li>
}</ul>
</body>
</html>
EJEMPLO 6
xquery version "3.1";
(: get a list links of titles form the Art and Design RSS feed of the New York Times in London & Brooklyn)
<html>
<head>
<tytle>Art and Design</tytle>
</head>
<body>
<h1>List of titles form the Art and Design</h1>
<ul>{for $item in doc("http://www.nytimes.com/services/xml/rss/nyt/ArtandDesign.xml")//item where matches($item,".*London.*") or matches($item,".*Brooklyn.*")return<li><a href="{fn:string($item/link)}">{fn:string($item/title)}</a> </li> }</ul> </body> </html>