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 -
- Next >