Wednesday, 29 August 2012

WEATHER WEB PART IN SHAREPOINT 2010

Weather web part is used to display weather forecast of your city.
Simple steps to add weather webpart in your sharepoint home page.
-->Simply add Xml webpart in your home page
Steps to add XML webpart
Page-->Edit Page-->Insert-->Add Webpart-->Content Rollup-->Xml Viewer
-->Then you can see that webpart in homepage
-->In this edit webpart-->click XSL Editor
 Paste the following code....

<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:yweather="http://xml.weather.yahoo.com/ns/rss/1.0" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:ddwrt2="urn:frontpage:internal">
<xsl:output method="html" indent="yes"/>

<xsl:template match="/" xmlns:yweather="http://xml.weather.yahoo.com/ns/rss/1.0" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime">

            <xsl:variable name="scale">
    <xsl:value-of select="rss/channel/yweather:units/@temperature"/>
</xsl:variable>

<table width="100%" border="0" cellspacing="0" cellpadding="3" class="Normal">
  <tr bgcolor="#075C70">
    <td colspan="2"><strong><font color="white">Weather Report - <xsl:value-of select="rss/channel/item/title"/></font></strong></td>
  </tr>
  <tr>
    <td><strong><font size="4"><xsl:value-of select="rss/channel/item/yweather:condition/@temp"/><xsl:text>&#176;</xsl:text><xsl:copy-of select="$scale" /></font></strong><br/>
      High <xsl:value-of select="rss/channel/item/yweather:forecast/@high"/> <xsl:text>&#176;</xsl:text><xsl:copy-of select="$scale" /> <br/>
      Low <xsl:value-of select="rss/channel/item/yweather:forecast/@low"/> <xsl:text>&#176;</xsl:text><xsl:copy-of select="$scale" /> </td>
    <td>
          <xsl:text disable-output-escaping="yes">&lt;img src="http://us.i1.yimg.com/us.yimg.com/i/us/we/52/</xsl:text>
      <xsl:value-of select="rss/channel/item/yweather:condition/@code"/>
          <xsl:text disable-output-escaping="yes">.gif"/&gt;</xsl:text>
      <br/>
      <xsl:value-of select="rss/channel/item/yweather:condition/@text"/></td>
  </tr>
  </table>

</xsl:template>

</xsl:stylesheet>

Click Ok.In the same page add the following link
XML Link
To link to an XML file, type a URL. 
http://weather.yahooapis.com/forecastrss?u=c&z= 600010
The highlighted field is your city pin code.you can change here.Thats it.now you can see your city weather   Report.

No comments:

Post a Comment