Peeking into the XML Result Set in a Web Part
Here’s a nice little trick to see what’s in the XML stream being returned in a Data View Web Part (DVWP), or any other Web Part where you can specify the XSL. By replacing the <xsl:stylesheet> code in your Web Part (between the <Xsl></Xsl>
tags) with the following, you get a simple result set which shows you all of the column values.
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ddwrt2="urn:frontpage:internal"> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()" /> </xsl:copy> </xsl:template> </xsl:stylesheet>
I read about this trick in the context of seeing what Search results look like, but it’s potentially useful anywhere you can plant this XSL in a Web Part. Depending on where you use it, you may need to view the page source to see the results.
An example of the results of this from a Custom List I’ve been using to test various things lately is:
<dsQueryResponse> <Rows> <Row Title="Bob" Start_x0020_Time="2009-05-14T15:00:00Z" End_x0020_Time="2009-05-14T20:00:00Z" ZIP_x0020_Code="12345" Amount="10" Nominee="<nobr><span><A HREF="/Intranet/TestSite/_layouts/userdisp.aspx?ID=7">Peter J Sterpe</A><img border="0" height="1" width="3" src="/_layouts/images/blank.gif"/><a href='javascript:' onclick='IMNImageOnClick();return false;' class='ms-imnlink'><img name='imnmark' title='' border='0' height='12' width='12' src='/_layouts/images/blank.gif' alt='No presence information' <a href="mailto:sip='[email protected]'">sip='[email protected]'</a> id='imn_725,type=smtp'/></a></span></nobr>" ID="1" ContentType="Item" Modified="2009-05-22T18:15:58Z" Created="2009-05-14T18:14:36Z" Author="<nobr><span><A HREF="/Intranet/TestSite/_layouts/userdisp.aspx?ID=3">Marc D Anderson</A><img border="0" height="1" width="3" src="/_layouts/images/blank.gif"/><a href='javascript:' onclick='IMNImageOnClick();return false;' class='ms-imnlink'><img name='imnmark' title='' border='0' height='12' width='12' src='/_layouts/images/blank.gif' alt='No presence information' <a href="mailto:sip='[email protected]'">sip='[email protected]'</a> id='imn_726,type=smtp'/></a></span></nobr>" Editor="<nobr><span><A HREF="/Intranet/TestSite/_layouts/userdisp.aspx?ID=3">Marc D Anderson</A><img border="0" height="1" width="3" src="/_layouts/images/blank.gif"/><a href='javascript:' onclick='IMNImageOnClick();return false;' class='ms-imnlink'><img name='imnmark' title='' border='0' height='12' width='12' src='/_layouts/images/blank.gif' alt='No presence information' <a href="mailto:sip='[email protected]'">sip='[email protected]'</a> id='imn_727,type=smtp'/></a></span></nobr>" _UIVersionString="1.0" Attachments="1" LinkTitleNoMenu="Bob" LinkTitle="Bob" FileRef="/Intranet/TestSite/Lists/Assignments/1_.000" FileDirRef="Intranet/TestSite/Lists/Assignments" FSObjType="0" ProgId="" ScopeId="{B9FF1AB2-473C-4AD4-86C0-8E8676676E85}" DocIcon="" MetaInfo="" /> <Row Title="Chrissy" Start_x0020_Time="2009-05-14T20:00:00Z" End_x0020_Time="2009-05-15T00:00:00Z" ZIP_x0020_Code="" Amount="20" Nominee="<nobr><span><A HREF="/Intranet/TestSite/_layouts/userdisp.aspx?ID=104">Marc Anderson</A><img border="0" height="1" width="3" src="/_layouts/images/blank.gif"/><a href='javascript:' onclick='IMNImageOnClick();return false;' class='ms-imnlink'><img name='imnmark' title='' border='0' height='12' width='12' src='/_layouts/images/blank.gif' alt='No presence information' <a href="mailto:sip='[email protected]'">sip='[email protected]'</a> id='imn_728,type=smtp'/></a></span></nobr>" ID="2" ContentType="Item" Modified="2009-05-22T18:16:02Z" Created="2009-05-14T18:17:16Z" Author="<nobr><span><A HREF="/Intranet/TestSite/_layouts/userdisp.aspx?ID=3">Marc D Anderson</A><img border="0" height="1" width="3" src="/_layouts/images/blank.gif"/><a href='javascript:' onclick='IMNImageOnClick();return false;' class='ms-imnlink'><img name='imnmark' title='' border='0' height='12' width='12' src='/_layouts/images/blank.gif' alt='No presence information' <a href="mailto:sip='[email protected]'">sip='[email protected]'</a> id='imn_729,type=smtp'/></a></span></nobr>" Editor="<nobr><span><A HREF="/Intranet/TestSite/_layouts/userdisp.aspx?ID=3">Marc D Anderson</A><img border="0" height="1" width="3" src="/_layouts/images/blank.gif"/><a href='javascript:' onclick='IMNImageOnClick();return false;' class='ms-imnlink'><img name='imnmark' title='' border='0' height='12' width='12' src='/_layouts/images/blank.gif' alt='No presence information' <a href="mailto:sip='[email protected]'">sip='[email protected]'</a> id='imn_730,type=smtp'/></a></span></nobr>" _UIVersionString="1.0" Attachments="0" LinkTitleNoMenu="Chrissy" LinkTitle="Chrissy" FileRef="/Intranet/TestSite/Lists/Assignments/2_.000" FileDirRef="Intranet/TestSite/Lists/Assignments" FSObjType="0" ProgId="" ScopeId="{B9FF1AB2-473C-4AD4-86C0-8E8676676E85}" DocIcon="" MetaInfo="" /> <Row Title="Bob" Start_x0020_Time="" End_x0020_Time="" ZIP_x0020_Code="" Amount="30" Nominee="<nobr><span><A HREF="/Intranet/TestSite/_layouts/userdisp.aspx?ID=7">Peter J Sterpe</A><img border="0" height="1" width="3" src="/_layouts/images/blank.gif"/><a href='javascript:' onclick='IMNImageOnClick();return false;' class='ms-imnlink'><img name='imnmark' title='' border='0' height='12' width='12' src='/_layouts/images/blank.gif' alt='No presence information' <a href="mailto:sip='[email protected]'">sip='[email protected]'</a> id='imn_731,type=smtp'/></a></span></nobr>" ID="3" ContentType="Item" Modified="2009-05-22T18:16:08Z" Created="2009-05-21T02:25:57Z" Author="<nobr><span><A HREF="/Intranet/TestSite/_layouts/userdisp.aspx?ID=3">Marc D Anderson</A><img border="0" height="1" width="3" src="/_layouts/images/blank.gif"/><a href='javascript:' onclick='IMNImageOnClick();return false;' class='ms-imnlink'><img name='imnmark' title='' border='0' height='12' width='12' src='/_layouts/images/blank.gif' alt='No presence information' <a href="mailto:sip='[email protected]'">sip='[email protected]'</a> id='imn_732,type=smtp'/></a></span></nobr>" Editor="<nobr><span><A HREF="/Intranet/TestSite/_layouts/userdisp.aspx?ID=3">Marc D Anderson</A><img border="0" height="1" width="3" src="/_layouts/images/blank.gif"/><a href='javascript:' onclick='IMNImageOnClick();return false;' class='ms-imnlink'><img name='imnmark' title='' border='0' height='12' width='12' src='/_layouts/images/blank.gif' alt='No presence information' <a href="mailto:sip='[email protected]'">sip='[email protected]'</a> id='imn_733,type=smtp'/></a></span></nobr>" _UIVersionString="1.0" Attachments="0" LinkTitleNoMenu="Bob" LinkTitle="Bob" FileRef="/Intranet/TestSite/Lists/Assignments/3_.000" FileDirRef="Intranet/TestSite/Lists/Assignments" FSObjType="0" ProgId="" ScopeId="{B9FF1AB2-473C-4AD4-86C0-8E8676676E85}" DocIcon="" MetaInfo="" /> <Row Title="Mabel" Start_x0020_Time="" End_x0020_Time="" ZIP_x0020_Code="" Amount="50" Nominee="<nobr><span><A HREF="/Intranet/TestSite/_layouts/userdisp.aspx?ID=12">Mike Lefkowitz</A><img border="0" height="1" width="3" src="/_layouts/images/blank.gif"/><a href='javascript:' onclick='IMNImageOnClick();return false;' class='ms-imnlink'><img name='imnmark' title='' border='0' height='12' width='12' src='/_layouts/images/blank.gif' alt='No presence information' <a href="mailto:sip='[email protected]'">sip='[email protected]'</a> id='imn_734,type=smtp'/></a></span></nobr>" ID="4" ContentType="Item" Modified="2009-05-22T18:16:33Z" Created="2009-05-21T02:26:59Z" Author="<nobr><span><A HREF="/Intranet/TestSite/_layouts/userdisp.aspx?ID=3">Marc D Anderson</A><img border="0" height="1" width="3" src="/_layouts/images/blank.gif"/><a href='javascript:' onclick='IMNImageOnClick();return false;' class='ms-imnlink'><img name='imnmark' title='' border='0' height='12' width='12' src='/_layouts/images/blank.gif' alt='No presence information' <a href="mailto:sip='[email protected]'">sip='[email protected]'</a> id='imn_735,type=smtp'/></a></span></nobr>" Editor="<nobr><span><A HREF="/Intranet/TestSite/_layouts/userdisp.aspx?ID=3">Marc D Anderson</A><img border="0" height="1" width="3" src="/_layouts/images/blank.gif"/><a href='javascript:' onclick='IMNImageOnClick();return false;' class='ms-imnlink'><img name='imnmark' title='' border='0' height='12' width='12' src='/_layouts/images/blank.gif' alt='No presence information' <a href="mailto:sip='[email protected]'">sip='[email protected]'</a> id='imn_736,type=smtp'/></a></span></nobr>" _UIVersionString="1.0" Attachments="0" LinkTitleNoMenu="Mabel" LinkTitle="Mabel" FileRef="/Intranet/TestSite/Lists/Assignments/4_.000" FileDirRef="Intranet/TestSite/Lists/Assignments" FSObjType="0" ProgId="" ScopeId="{B9FF1AB2-473C-4AD4-86C0-8E8676676E85}" DocIcon="" MetaInfo="" /> <Row Title="Lucas" Start_x0020_Time="" End_x0020_Time="" ZIP_x0020_Code="" Amount="100" Nominee="<nobr><span><A HREF="/Intranet/TestSite/_layouts/userdisp.aspx?ID=17">Sat Guiterrez</A><img border="0" height="1" width="3" src="/_layouts/images/blank.gif"/><a href='javascript:' onclick='IMNImageOnClick();return false;' class='ms-imnlink'><img name='imnmark' title='' border='0' height='12' width='12' src='/_layouts/images/blank.gif' alt='No presence information' <a href="mailto:sip='[email protected]'">sip='[email protected]'</a> id='imn_737,type=smtp'/></a></span></nobr>" ID="5" ContentType="Item" Modified="2009-05-22T18:16:23Z" Created="2009-05-21T03:35:47Z" Author="<nobr><span><A HREF="/Intranet/TestSite/_layouts/userdisp.aspx?ID=3">Marc D Anderson</A><img border="0" height="1" width="3" src="/_layouts/images/blank.gif"/><a href='javascript:' onclick='IMNImageOnClick();return false;' class='ms-imnlink'><img name='imnmark' title='' border='0' height='12' width='12' src='/_layouts/images/blank.gif' alt='No presence information' <a href="mailto:sip='[email protected]'">sip='[email protected]'</a> id='imn_738,type=smtp'/></a></span></nobr>" Editor="<nobr><span><A HREF="/Intranet/TestSite/_layouts/userdisp.aspx?ID=3">Marc D Anderson</A><img border="0" height="1" width="3" src="/_layouts/images/blank.gif"/><a href='javascript:' onclick='IMNImageOnClick();return false;' class='ms-imnlink'><img name='imnmark' title='' border='0' height='12' width='12' src='/_layouts/images/blank.gif' alt='No presence information' <a href="mailto:sip='[email protected]'">sip='[email protected]'</a> id='imn_739,type=smtp'/></a></span></nobr>" _UIVersionString="1.0" Attachments="0" LinkTitleNoMenu="Lucas" LinkTitle="Lucas" FileRef="/Intranet/TestSite/Lists/Assignments/5_.000" FileDirRef="Intranet/TestSite/Lists/Assignments" FSObjType="0" ProgId="" ScopeId="{B9FF1AB2-473C-4AD4-86C0-8E8676676E85}" DocIcon="" MetaInfo="" /> <Row Title="Bob" Start_x0020_Time="" End_x0020_Time="" ZIP_x0020_Code="" Amount="2000" Nominee="<nobr><span><A HREF="/Intranet/TestSite/_layouts/userdisp.aspx?ID=7">Peter J Sterpe</A><img border="0" height="1" width="3" src="/_layouts/images/blank.gif"/><a href='javascript:' onclick='IMNImageOnClick();return false;' class='ms-imnlink'><img name='imnmark' title='' border='0' height='12' width='12' src='/_layouts/images/blank.gif' alt='No presence information' <a href="mailto:sip='[email protected]'">sip='[email protected]'</a> id='imn_740,type=smtp'/></a></span></nobr>" ID="6" ContentType="Item" Modified="2009-05-22T18:16:11Z" Created="2009-05-21T03:36:11Z" Author="<nobr><span><A HREF="/Intranet/TestSite/_layouts/userdisp.aspx?ID=3">Marc D Anderson</A><img border="0" height="1" width="3" src="/_layouts/images/blank.gif"/><a href='javascript:' onclick='IMNImageOnClick();return false;' class='ms-imnlink'><img name='imnmark' title='' border='0' height='12' width='12' src='/_layouts/images/blank.gif' alt='No presence information' <a href="mailto:sip='[email protected]'">sip='[email protected]'</a> id='imn_741,type=smtp'/></a></span></nobr>" Editor="<nobr><span><A HREF="/Intranet/TestSite/_layouts/userdisp.aspx?ID=3">Marc D Anderson</A><img border="0" height="1" width="3" src="/_layouts/images/blank.gif"/><a href='javascript:' onclick='IMNImageOnClick();return false;' class='ms-imnlink'><img name='imnmark' title='' border='0' height='12' width='12' src='/_layouts/images/blank.gif' alt='No presence information' <a href="mailto:sip='[email protected]'">sip='[email protected]'</a> id='imn_742,type=smtp'/></a></span></nobr>" _UIVersionString="1.0" Attachments="0" LinkTitleNoMenu="Bob" LinkTitle="Bob" FileRef="/Intranet/TestSite/Lists/Assignments/6_.000" FileDirRef="Intranet/TestSite/Lists/Assignments" FSObjType="0" ProgId="" ScopeId="{B9FF1AB2-473C-4AD4-86C0-8E8676676E85}" DocIcon="" MetaInfo="" /> <Row Title="Lucas" Start_x0020_Time="" End_x0020_Time="" ZIP_x0020_Code="" Amount="2000" Nominee="<nobr><span><A HREF="/Intranet/TestSite/_layouts/userdisp.aspx?ID=17">Sat Guiterrez</A><img border="0" height="1" width="3" src="/_layouts/images/blank.gif"/><a href='javascript:' onclick='IMNImageOnClick();return false;' class='ms-imnlink'><img name='imnmark' title='' border='0' height='12' width='12' src='/_layouts/images/blank.gif' alt='No presence information' <a href="mailto:sip='[email protected]'">sip='[email protected]'</a> id='imn_743,type=smtp'/></a></span></nobr>" ID="7" ContentType="Item" Modified="2009-05-22T18:16:20Z" Created="2009-05-21T03:43:19Z" Author="<nobr><span><A HREF="/Intranet/TestSite/_layouts/userdisp.aspx?ID=3">Marc D Anderson</A><img border="0" height="1" width="3" src="/_layouts/images/blank.gif"/><a href='javascript:' onclick='IMNImageOnClick();return false;' class='ms-imnlink'><img name='imnmark' title='' border='0' height='12' width='12' src='/_layouts/images/blank.gif' alt='No presence information' <a href="mailto:sip='[email protected]'">sip='[email protected]'</a> id='imn_744,type=smtp'/></a></span></nobr>" Editor="<nobr><span><A HREF="/Intranet/TestSite/_layouts/userdisp.aspx?ID=3">Marc D Anderson</A><img border="0" height="1" width="3" src="/_layouts/images/blank.gif"/><a href='javascript:' onclick='IMNImageOnClick();return false;' class='ms-imnlink'><img name='imnmark' title='' border='0' height='12' width='12' src='/_layouts/images/blank.gif' alt='No presence information' <a href="mailto:sip='[email protected]'">sip='[email protected]'</a> id='imn_745,type=smtp'/></a></span></nobr>" _UIVersionString="1.0" Attachments="0" LinkTitleNoMenu="Lucas" LinkTitle="Lucas" FileRef="/Intranet/TestSite/Lists/Assignments/7_.000" FileDirRef="Intranet/TestSite/Lists/Assignments" FSObjType="0" ProgId="" ScopeId="{B9FF1AB2-473C-4AD4-86C0-8E8676676E85}" DocIcon="" MetaInfo="" /> <Row Title="Chrissy" Start_x0020_Time="" End_x0020_Time="" ZIP_x0020_Code="" Amount="123" Nominee="<nobr><span><A HREF="/Intranet/TestSite/_layouts/userdisp.aspx?ID=104">Marc Anderson</A><img border="0" height="1" width="3" src="/_layouts/images/blank.gif"/><a href='javascript:' onclick='IMNImageOnClick();return false;' class='ms-imnlink'><img name='imnmark' title='' border='0' height='12' width='12' src='/_layouts/images/blank.gif' alt='No presence information' <a href="mailto:sip='[email protected]'">sip='[email protected]'</a> id='imn_746,type=smtp'/></a></span></nobr>" ID="8" ContentType="Item" Modified="2009-05-22T18:16:16Z" Created="2009-05-21T03:53:30Z" Author="<nobr><span><A HREF="/Intranet/TestSite/_layouts/userdisp.aspx?ID=3">Marc D Anderson</A><img border="0" height="1" width="3" src="/_layouts/images/blank.gif"/><a href='javascript:' onclick='IMNImageOnClick();return false;' class='ms-imnlink'><img name='imnmark' title='' border='0' height='12' width='12' src='/_layouts/images/blank.gif' alt='No presence information' <a href="mailto:sip='[email protected]'">sip='[email protected]'</a> id='imn_747,type=smtp'/></a></span></nobr>" Editor="<nobr><span><A HREF="/Intranet/TestSite/_layouts/userdisp.aspx?ID=3">Marc D Anderson</A><img border="0" height="1" width="3" src="/_layouts/images/blank.gif"/><a href='javascript:' onclick='IMNImageOnClick();return false;' class='ms-imnlink'><img name='imnmark' title='' border='0' height='12' width='12' src='/_layouts/images/blank.gif' alt='No presence information' <a href="mailto:sip='[email protected]'">sip='[email protected]'</a> id='imn_748,type=smtp'/></a></span></nobr>" _UIVersionString="1.0" Attachments="0" LinkTitleNoMenu="Chrissy" LinkTitle="Chrissy" FileRef="/Intranet/TestSite/Lists/Assignments/8_.000" FileDirRef="Intranet/TestSite/Lists/Assignments" FSObjType="0" ProgId="" ScopeId="{B9FF1AB2-473C-4AD4-86C0-8E8676676E85}" DocIcon="" MetaInfo="" /> </Rows> </dsQueryResponse>
I guess this won’t work as written here – the XSL has a quote in the HREF URL embedded within in a quote delimiting the xmlns:xsl so that will give you a syntax error if you try to paste in into a page and anway the namspace should just be a URL. Has anyone got this working? I tried tha XSL from MSDN here (http://msdn.microsoft.com/en-us/library/ms546985.aspx) but it just doesn’t display anything.
It actually did work as written, but it looks like WordPress’ [sourcecode language=”xml”] method isn’t working for us here. I really like the way it formats code in general, but sometimes the escaping isn’t quite right.
It ought to just look like this:
xmlns:xsl=”http://www.w3.org/1999/XSL/Transform/”
M.