I am trying to extract data, to use in a rss feed for google base currently using SQL Server 2005.
There a few problems we have, which i hope can be solved!
- namespaces
- grouping
My current sql is as follows:
SELECT [xml].query('
<Item xmlns:g="a">
<Title>{ data(*/*/*/Title) }</Title>
<g:id>{ sql:column("ReportingCode") }</g:id>
</Item>
')
FROM esh_xml
where [Xml].value('(/*/*/*/Attributes/Attribute[@Description="Category"][text()="MasterMix"])[1]','nvarchar(2000)') is not null
as output with the current query I get many thousands of results rows ie
<item xmlns:g="a"><title>blah blah</title><g:id>asdasd<g:id></item>
my desired output would be
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:g="http://base.google.com/ns/1.0">
<channel>
<title>Mastermixdigital.com Product Feed </title>
<link> http://www.mysite.com/ </link>
<description>mastermix latest release feed </description>
<item xmlns:g="a">
<title>blah blah</title>
<g:id>asdasd<g:id>
</item>
<item xmlns:g="a">
<title>blah blah</title>
<g:id>asdasd<g:id>
</item>
<item xmlns:g="a">
<title>blah blah</title>
<g:id>asdasd<g:id>
</item>
</channel>
</rss>
Another thing I believe the execution of the query could be sped up by removing redundant nodes before searching through, and any tips on how i might go about this!
Many thanks