Paul Galvin's (old) SharePoint space [SharePoint

Just another WordPress.com site

MOSS/WSS Search results (and dataviews): view the raw XML data

This may be obvious to many, but while studying for my MOSS programming exam, I learned that it’s pretty easy to get the actual XML from a search query via the user interface.

One quick method is as follows:

  • Access advanced search.
  • Perform a search that returns some data.
  • Edit the page (via site settings).
  • Change the XSL to 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="/">
    <
pre>
      <
xsl:copy-of select="*"/>
    </
pre>
  </
xsl:template>
</
xsl:stylesheet>

  • Hit apply.
  • View Source in the browser.

Note that the <pre> tag doesn’t do much except serve as a convenient marker when you view the results. 

This trick can be very helpful when working with managed properties and customizing search.  It will provide a definitive list of the XML available for you to use in your xslt which would have been very helpful the last 25 times I created some customized search results.

This ought to work for dataviews as well, though I have not tested that out as yet.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: