Using XML and XSL in SharePoint

Written By: Ved Mishra -- 7/20/2011 -- join -- contribute -- (1999) comments -- printer friendly version

Rating: Rate --

Categories: Design, MOSS 2007, Programming and Customizations, SharePoint Designer 2007, Web Parts, WSS3

< Prev - 1 | 2 | 3 | - Next > | Become a paid author


The standard approach for data storage in SharePoint is lists and libraries. However, there are a few scenarios where you need to deal with XML data. Consider a scenario where you need to integrate a flash component in SharePoint which has dynamic XML data. Or consider another case where you need to manipulate XML data returned by a web service.

XML is more suitable for hierarchical data. So in some cases you would want list data to be converted into XML first, before doing any manipulation. Now the next question is - how would you render the output as desired HTML from an XML data source?


XSLT (eXtensible Stylesheet Language Transformations) comes to the rescue for XML data presentation. XSLT is the recommended style sheet language of XML. XSLT can be used to transform XML into HTML, before it is displayed by a browser. There are various mechanisms in SharePoint which can be used to display XML data using XSL Transformation. We will discuss various approaches(Data View, XML web part and Custom Code) as follows.

For the purposes of this article, let us consider the following XML data. To download the XML click here

Data View / Form Web Parts (DVWP): DVWPs are able to retrieve data from various data sources in the form of XML, even if the data itself in its original form is not XML. The eXtensible Stylesheet Language Transformations (XSLT) can be used to change the appearance of returned data. These web parts can only be created using SharePoint Designer (SPD). Now that SharePoint Designer 2007 is free, this opens the door to a lot more people being able to create these web parts, without any need of server access or deployment. Follow these steps to create a DVWP with XML as data source.

- Launch SharePoint Designer and open the site. Open the page in SPD where you want to add the DVWP.

- Select the web part zone, go to Data View toolbar and click on "Insert Data View"

- Before you can use the XML as a data source, you need to upload it somewhere in the site. I prefer to upload it in a separate folder in Style library. Once done, go back to SPD and expand the XML files under the Data Source Library. Click on 'Add an XML file' if you don't see your XML listed there.

- Browse to the location where you uploaded your xml and click Open. Click OK on the next window.

- Click on the down arrow beside the XML file and click on "Show Data".

- Select the field that you want to show and click on Insert as Multiple Item View. In this case, we will select title, audience and issue

- Save the page and see it in the browser or design window.

< Prev - 1 | 2 | 3 | - Next >

Learn more about SharePoint

Sponsor Information

Copyright (c) 2010-2017 Edgewood Solutions, LLC All rights reserved
privacy | disclaimer | copyright | advertise | contribute | feedback | about
Some names and products listed are the registered trademarks of their respective owners. |