Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer 1

up vote 1 down vote accepted

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.

share|improve this answer
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. –  Dave Paylor Mar 19 '13 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 Mar 19 '13 at 20:31
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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