If you follow one or more blogs, you have probably heard about RSS.
Several varieties of the RSS format exist, so I will refer to them collectively as "feeds" (and when I say "RSS" I really mean any kind of feed).
RSS can be used to publish not just blogs, but also other kinds of information, such as news updates, audit trails, log entries, and so on.
The Alexandria library for PL/SQL contains RSS_UTIL_PKG, a package for publishing and parsing RSS feeds.
In this blog post I will describe how we can use this package to read (parse) RSS feeds. A follow-up post will describe how the same package can be used to publish any query as a feed.
Reading an RSS feed with SQL
The RSS_UTIL_PKG package contains a pipelined function named RSS_TO_TABLE which can be used in a SQL query to extract feed values.
A single line to read an RSS feed, that's not too shabby, eh?
Reading an RSS feed with PL/SQL
Another function in the RSS_UTIL_PKG is RSS_TO_LIST, which returns a PL/SQL associative array.
After the feed has been parsed to a list, you can loop through it and perform any required processing.
Of course you could also use the pipelined function in a cursor FOR loop, depending on your coding style.
Creating a report in Apex based on an RSS feed
Since you can use RSS_TO_TABLE in SQL statements, you can also use it as the basis for a report region in Apex.
Create a page and add a text item to input the URL of an RSS feed.
Then add a report region (classic or interactive) and use the following query as the report source:
Running the page produces the following result:
That's it for reading (parsing) RSS feeds. In my next blog post I will describe how to publish RSS feeds from the database using PL/SQL and SQL.