<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: rss code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Tue, 07 Oct 2008 19:02:04 GMT</pubDate>
    <description>DZone Snippets: rss code</description>
    <item>
      <title>Importing XML into a database with Scriptella ETL</title>
      <link>http://snippets.dzone.com/posts/show/3534</link>
      <description>The following &lt;a href="http://scriptella.javaforge.com"&gt;Scriptella ETL&lt;/a&gt; simple usage example imports RSS file into a database table.&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;!DOCTYPE etl SYSTEM "http://scriptella.javaforge.com/dtd/etl.dtd"&gt;&lt;br /&gt;&lt;etl&gt;&lt;br /&gt;    &lt;connection id="in" driver="xpath" url="http://snippets.dzone.com/rss"/&gt;&lt;br /&gt;    &lt;connection id="db" driver="hsqldb" url="jdbc:hsqldb:db/rss" user="sa" classpath="hsqldb.jar"/&gt;&lt;br /&gt;classpath="hsqldb.jar"/&gt;&lt;br /&gt;    &lt;query connection-id="in"&gt;&lt;br /&gt;        /rss/channel/item&lt;br /&gt;        &lt;script connection-id="db"&gt;&lt;br /&gt;            INSERT INTO Rss (ID, Title, Description, Link) &lt;br /&gt;            VALUES (?rownum, ?title, ?description, ?link);&lt;br /&gt;        &lt;/script&gt;&lt;br /&gt;    &lt;/query&gt;&lt;br /&gt;&lt;/etl&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Here is the full version of the example described above. It creates an RSS table, downloads rss file, inserts rss records into a database, converts rss.xml to a plain text file and saves it to rss.txt.&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;!DOCTYPE etl SYSTEM "http://scriptella.javaforge.com/dtd/etl.dtd"&gt;&lt;br /&gt;&lt;etl&gt;&lt;br /&gt;    &lt;connection id="in" driver="xpath" url="http://snippets.dzone.com/rss"/&gt;&lt;br /&gt;    &lt;connection id="out" driver="text" url="rss.txt"/&gt;&lt;br /&gt;    &lt;connection id="db" driver="hsqldb" url="jdbc:hsqldb:db/rss" user="sa" classpath="hsqldb.jar"/&gt;&lt;br /&gt;    &lt;script connection-id="db"&gt;&lt;br /&gt;       CREATE TABLE Rss (&lt;br /&gt;           ID Integer,&lt;br /&gt;           Title VARCHAR(255),&lt;br /&gt;           Description VARCHAR(255),   &lt;br /&gt;           Link VARCHAR(255)&lt;br /&gt;&lt;br /&gt;       )&lt;br /&gt;    &lt;/script&gt;&lt;br /&gt;    &lt;query connection-id="in"&gt;&lt;br /&gt;        /rss/channel/item&lt;br /&gt;        &lt;script connection-id="out"&gt;&lt;br /&gt;            Title: $title&lt;br /&gt;            Description: [&lt;br /&gt;            ${description.substring(0, 20)}...&lt;br /&gt;            ]&lt;br /&gt;            Link: $link&lt;br /&gt;            ----------------------------------&lt;br /&gt;        &lt;/script&gt;&lt;br /&gt;        &lt;script connection-id="db"&gt;&lt;br /&gt;            INSERT INTO Rss (ID, Title, Description, Link) &lt;br /&gt;            VALUES (?rownum, ?title, ?description, ?link);&lt;br /&gt;        &lt;/script&gt;&lt;br /&gt;    &lt;/query&gt;&lt;br /&gt;&lt;/etl&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sun, 18 Feb 2007 19:07:06 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3534</guid>
      <author>ejboy (Fyodor Kupolov)</author>
    </item>
  </channel>
</rss>
