Apply a Style to the XML Viewer Web Part
XML Viewer web part for SharePoint 2010 (Called XML Web Part under SharePoint 2007) is a very useful to display structured data and XML-based documents. The good thing about this XML web part is that it allows you to customize your XML document with the help of XSLT (Extensible Stylesheet Language Transformations) by applying the style to the XML before the content is displayed. There are many ways of using the XML Viewer web part, but for now I will concentrate on displaying a RSS feed. And what better feed I could come up with than the TopSharePoint.com Blog feed.
So, let’s start with adding the web part to the page. Click on Site Action and then select Edit Page.
Pick a side where the new XML Viewer will be displayed on the page. For this example I used the right panel. Click on the “Add a Web Part” link and then under the top ribbon make sure you’re under Browse tab.
Select Content Rollup and then XML Viewer and click on the Add button.
Under the newly added web part click on the “open the tool pane” link to customize it.
On the XML Viewer web part settings panel, under XML Link plug in your RSS feed and then click on XSL Editor button to get to the Text Editor webpage dialog window.
Copy & Paste the code below and then click OK.
version="1.0"?>
|
Make the necessary aesthetics changes: web part Title, Width, Height and Chrome Type and click OK.
Of course the XSL style sheet provided can be customized farther, like referencing an external CSS by adding a class attribute to the div tag instead of using inline styling. And, here is the outcome:
And here is the XSL for an Atom feed:
version="1.0" encoding="UTF-8"?>
|
Thanks so much! Using this on site intranet to display twitter updates. With minor modifications, this is exactly what I’ve been looking for!!
I have followed the same steps but have this error:
Cannot retrieve the URL specified in the XML Link property. For more assistance, contact your site administrator.
Any idea?
Muchas gracias un valioso aporte, funciona perfecto.
I’m using this technique for my external facing Blog, which is SP2010. I’m just learning xsl, but can you illustrate how to bold the Title and remove the “Body:” caption? I dont mind the Category of published date, but want to remove the BODY and bold the title. My list show as:
Blog Title <—- Not bold
BODY: <—– Bold
blog content
Category: Category 1
Published: 12/12/2011 11:19AM
Eric, for Title it’s all in CSS as per the Body, play with “description”. I would remove the whole line: xsl:value-of disable-output-escaping=”yes” select=”description”
Nice article , thanks to giving this simple solution. Thanks.
XML Viewer
Cannot retrieve the URL specified in the XML Link property. For more assistance, contact your site administrator.
i cannot apply.. can you give me an advice please?