1

I would like to see the Raw XML that is output from a content query web part so that I can develop a custom xsl stylesheet for this.

I have the publishing infrastructure enabled. I assume I can do this by editing the ContentQueryMain.xsl file in Style Library -> XSL Style Sheets.

However I am not sure what the custom template will need to contain to view the Raw XML.

1 Answer 1

3

This article describes how to do it.

I had a need to view the raw XML being generated from a Content Query Web Part today, so I could see exactly what data was being returned in each column. This is how to do it. The PublishingResources feature of MOSS2007 contains a file entitled ContentQueryMain.xsl, which is the primary stylesheet for the webpart. Make sure you take a backup of that file before continuing! Open the file, and near the top is the following line: <xsl:output method="html" indent="no" /> Replace that line with the following:

 <xsl:output method="xml" indent="yes" /> 

Then scroll down a few lines and find the following snippet:

  <xsl:template match="/">
  <xsl:call-template name="OuterTemplate" />
 </xsl:template> 

Replace this with

  <xsl:template match="/">
  <xmp><xsl:copy-of select="*" /></xmp>
 </xsl:template> 

Save the file, IISReset, and that’s it! You can now see all the data returned by the Content Query Web Part in its native XML form, and see exactly what values are contained within each field.

3
  • 1
    If you are using SP2010 then I would suggest you link the CQWP to a copy of the XSL files and then edit the copy. You can do this through the properties of the web part in SharePoint Designer. You will not need IISRESET as suggested above. Commented Mar 19, 2013 at 20:29
  • fwiw that <xmp> node is important as not including it seems to mess up the case of the Xml nodes themselves. Microsoft details this same approach for the search results web part here : msdn.microsoft.com/en-us/library/ms546985%28v=office.14%29.aspx
    – Dave Wise
    Commented Mar 19, 2013 at 20:31
  • The IISRESET isn't needed, but the rest of the instructions are spot on.
    – iOnline247
    Commented Aug 19, 2015 at 19:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.