How to: View Search Results XML Data

Applies to: SharePoint Server 2010

The Search service application returns the search results to the requesting page as XML data. The XML data is then transformed by the search Web Parts into the HTML that is displayed on the search results page by using XSLT Transformation (XSLT) markup. You can modify the search results view by modifying the XSLT, but to do this, you should be familiar with the structure of the search results XML data.

This topic shows how to modify the XSLT that is used by the Core Results Web Part to display the raw XML that contains the search results data. You can use the steps described in this topic to modify the XSLT for search Web Parts, including the following Web Parts:

  • Federated Results

  • People Search Core Results

  • Refinement Panel

  • Related Queries

  • Search Best Bets

  • Search Core Results

  • Top Federated Results

To modify the Web Part's XSL property

  1. In your browser, navigate to the results page URL:

    https://ServerName/SiteName/Pages/results.aspx

  2. Click the Site Actions link, and then click Edit Page.

  3. In the Search Core Results Web Part, click the edit arrow to display the Web Part menu, and then click Edit Web Part. This opens the Web Part tool pane.

  4. In the Display Properties section, clear Use Location Visualization.

    Important

    The Related Queries, Refinement Panel, and Best Bets Web Parts do not have the Use Location Visualization check box in the tool pane, so this step does not apply to these Web Parts. Instead, for the Refinement Panel Web Part, you must clear Use Default Configuration in the Refinement section.

    For the Related Queries and Best Bets Web Parts, save a copy of the original XSLT code so that you can easily revert back to the original if needed. Alternatively, you could add a new instance of the Web Part to the page because any modifications you make to the XSL property apply only to that specific instance of the Web Part.

  5. To open the Text Entry Window for the XSL property, click the XSL Editor button. The XSL Editor button is located in the Display Properties section for all of the Web Parts, except for the Best Bets Web Part and Refinement Panel Web Part, where it is located in the Data View Properties section.

  6. Replace the default XSLT with the following.

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
    <xsl:template match="/">
    <xmp><xsl:copy-of select="*"/></xmp>
    </xsl:template>
    </xsl:stylesheet>
    

    This XSLT does not perform any actual transformation, so the search results will display the raw XML data.

  7. Click OK to save the changes to the Web Part.

  8. Type a query in the Search box, and then click the search button.

    Because the search results are rendered without the formatting provided by the XSLT, the raw XML for the search results data is displayed instead.