WSS Field Names for Lists & Document Libraries, Test your SPSiteDataQuery parameters using Snippet Compiler, Problems with WSS columns & internal field names, Specifying the Internal Name for WSS Columns, SPSiteDataQuery Samples for WSS v3
I like to use XML & XSLT to produce the HTML for a page. It gives a nice seperation from the code and the display. SharePoint makes it very easy to produce XML using the SPSiteDataQuery object in conjunction with GetSiteData(), all you need to do is add a DataSet.
Using the DataSet allows you to specify the containing element name (the name of the DataSet) and the name of the element for each item returned (the name of the DataTable). The example below shows how to produce a list of documents contained by the 'rows' element and with each item in the results contained in a 'row' element.
SPSiteDataQuery q = new SPSiteDataQuery();
q.Lists = "<Lists BaseType='1'/>";
q.Query = "<Where><Gt><FieldRef Name='ID' /><Value Type='Number'>0</Value></Gt></Where>";
q.Webs = "<Webs Scope='SiteCollection' />";
q.ViewFields = "<FieldRef Name='Title' /><FieldRef Name='ID' />"'
q.RowLimit = "10";
DataTable t = SPContext.Current.Web.GetSiteData(q);
t.TableName = "row";
DataSet ds = new DataSet("rows");
ds.Tables.Add(t);
XmlDocument oDoc = new XmlDocument();
oDoc.LoadXml(ds.GetXml());
This would result in XML similar to the following...
<rows>
<row>
<ListId>{35C70FD7-F0A3-4C74-ABD7-0697269AF838}</ListId>
<WebId>{C24CDF22-8557-4089-A4B9-613D819928BF}</WebId>
<ID>1</ID>
<Title>Home</Title>
</row>
<row>
<ListId>{3942E923-33CE-46CD-89B7-6E6952572C55}</ListId>
<WebId>{CB666C7E-5E2C-427D-82FA-2757AEB8EA05}</WebId>
<ID>1</ID>
<Title>Press Releases</Title>
</row>
</rows>