View the XML used in SharePoint web parts
I was customizing the XSLT for a Data View web part and wanted to see what the XML looked like as delivered to the web part from SharePoint. The following is one way to see this. (There are probably better ways.)
- Create a new view in your site. A simple standard view with the columns you need selected will do.
- Open SharePoint Designer and open your site.
- Expand Lists and find your list and then expand the list and find the new view.
- Double click the view and display in Design view.
- Note: the view is now being displayed using a ListViewWebPart and can only be customized from the browser ("Modify View")
- Right-click in the middle of the view and select Convert to XSLT Data View.
- Note: the view is now being displayed using a DataViewWebPart and can only be customized from SharePoint Designer or by editing the XSLT from the browser ("Modify View")
- Right-click the Data View web part and select Web Part Properties.
- Click the XSLT Builder Button (big name for the "…" button)
- Delete everything starting with "<xsl:decimal-format NaN="" />" down to, but not including "</xsl:stylesheet>".
- Just before the "</xsl:stylesheet>" tag enter:
<xsl:copy-of select="/" />
- Click Save, OK and then save your changes to the page.
- In the browser navigate to this view (which will look kind of empty), right-click and View Source.
- All of the text between START and END is the XML returned by SharePoint. This is what your XSLT needs to convert to HTML. Paste this into your favorite XML / XSLT editor and have fun!