Getting dc: creator value using SQL XML

I'm not sure how to get the dc: creator value from an RSS feed using SQL. This is my xml / rss feed:

<rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
<channel>
  <title>Foobar RSS</title>
  <link>http://www.foobar.com/</link>
  <description>RSS feed</description>
  <language>en</language>
  <ttl>15</ttl>
    <item>
        <title>This is my title</title>
        <link>http://www.foobar.com/link/blabla</link>
        <description>Bla..bla..bla..</description>
        <dc:creator>John Doe</dc:creator>
        <guid isPermaLink="false">00082EA751F1D905DE00E7CFA2417DA9</guid>
        <pubDate>Wed, 26 Oct 2011 00:00:00 +0200</pubDate>
    </item>
</channel>
</rss>

In my SQL, I use something similar to get the values ​​- for example, for pubDate I use something like this:

DECLARE @xml XML
SET @xml = cast('my rss feed here' AS xml) 

SELECT
convert(datetime,substring(T.nref.value('pubDate[1]','nvarchar(100)'),6,20)) as pubdate,
FROM @xml.nodes('//item') AS T(nref)

This works fine, but when I try to get the dc: creator "John Doe" value, the following just gives me an error:

SELECT
   T.nref.value('dc:creator','nvarchar(100)') as creator
FROM @xml.nodes('//item') AS T(nref)

   error: 
   XQuery [value()]: The name "dc" does not denote a namespace.

I need to be able to select multiple columns from an rss feed. Can someone provide a solution or direction to get the dc: creator value?

I have another question - how would you build the code if you do it in a selection?

E.g. 
INSERT INTO RSSResults (ID, pubDate)
SELECT @ID, tbl.pubDate FROM (     

;WITH XMLNAMESPACES('http://purl.org/dc/elements/1.1/' AS dc) 
    SELECT 
       RSS.Item.value('(dc:creator)[1]', 'nvarchar(100)') as pubDate
    FROM 
       @xml.nodes('/rss/channel/item') as RSS(Item)) AS tbl 

The code breaks into "; WITH XMLNAMESPACES". Is there any way to include the namespace directly in the statement?

+5
1

- :

DECLARE @xml XML
SET @xml = cast('my rss feed here' AS xml) 

;WITH XMLNAMESPACES('http://purl.org/dc/elements/1.1/' AS dc)
SELECT
    @xml.value('(rss/channel/item/dc:creator)[1]', 'nvarchar(100)')

- :

DECLARE @xml XML
SET @xml = cast('my rss feed here' AS xml) 

;WITH XMLNAMESPACES('http://purl.org/dc/elements/1.1/' AS dc)
SELECT
    RSS.Item.value('(dc:creator)[1]', 'nvarchar(100)')
FROM
    @xml.nodes('/rss/channel/item') as RSS(Item)
+8

All Articles