Skip to main content

Blogging about SharePoint

Go Search
Home
Blogging about SharePoint
Public Speaking
  

Michael Blumenthal's BlumenthalIT.NET > Blogging about SharePoint > Posts > Free Stock Quote Web Part
Free Stock Quote Web Part

An easy and cheap way to build a stock quote web part is to use the Data View Web Part and the apparently free Stock Quote Web Service from WebServiceX.Net.

I built one today in less than 75 minutes, and much of that was spent figuring out how I could use the substring-before and substring-after commands to parse the XML blob returned by the service. Now you can do it in 5 minutes.

Once I built this web part, I exported it to a .webpart file. A .webpart file is just an XML file, which means that if all you need is a stock quote for a single stock, you can just reuse this web part and you don't even need to go back into SharePoint Designer to change the ticker symbol.

So this is what you do:

  1. Take the content below and save it to a text file. You can either copy and paste below, or right click this link and "Save Target As…"
  2. Replace the MSFT ticker symbol with the symbol of your choice. See where I have highlighted it below.
  3. Rename the file to end in .webpart.
  4. Add (import) the web part to a web part zone on a web part page in a SharePoint site. When you are done, it should look like this.

If you need a refresher on using the Data View Web Part, Dustin Miller has an excellent webcast on this topic.

If for some reason, this stock quote web part doesn't meet your requirements, Data Springs makes some.

This is provided as-is, no warranties implied, etc. etc.

<webParts>

<webPart xmlns="http://schemas.microsoft.com/WebPart/v3">

<metaData>

<type name="Microsoft.SharePoint.WebPartPages.DataFormWebPart, Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />

<importErrorMessage>Cannot import this Web Part.</importErrorMessage>

</metaData>

<data>

<properties>

<property name="MissingAssembly" type="string">Cannot import this Web Part.</property>

<property name="FireInitialRow" type="bool">True</property>

<property name="TitleIconImageUrl" type="string" />

<property name="HelpMode" type="helpmode">Modeless</property>

<property name="CacheXslStorage" type="bool">True</property>

<property name="ViewContentTypeId" type="string" />

<property name="Description" type="string" />

<property name="DataSourcesString" type="string">&lt;%@ Register TagPrefix="sharepoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %&gt;&lt;sharepoint:SoapDataSource runat="server" SelectUrl="http://www.webservicex.net/stockquote.asmx" InsertUrl="" UpdateUrl="" DeleteUrl="" SelectAction="http://www.webserviceX.NET/GetQuote" InsertAction="" UpdateAction="" DeleteAction="" SelectPort="StockQuoteSoap" InsertPort="" UpdatePort="" DeletePort="" SelectServiceName="StockQuote" InsertServiceName="" UpdateServiceName="" DeleteServiceName="" AuthType="None" WsdlPath="http://www.webservicex.net/stockquote.asmx?WSDL" XPath="" ID="SoapDataSource4"&gt;&lt;SelectCommand&gt;

&lt;soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"&gt;&lt;soap:Body&gt;&lt;GetQuote xmlns="http://www.webserviceX.NET/"&gt;&lt;symbol&gt;MSFT&lt;/symbol&gt;&lt;/GetQuote&gt;&lt;/soap:Body&gt;&lt;/soap:Envelope&gt;&lt;/SelectCommand&gt;

&lt;InsertCommand&gt;

&lt;/InsertCommand&gt;

&lt;UpdateCommand&gt;

&lt;/UpdateCommand&gt;

&lt;DeleteCommand&gt;

&lt;/DeleteCommand&gt;

&lt;/sharepoint:SoapDataSource&gt;

</property>

<property name="AllowZoneChange" type="bool">True</property>

<property name="ParameterBindings" type="string">

                        &lt;ParameterBinding Name="dvt_apos" Location="Postback;Connection"/&gt;

                        &lt;ParameterBinding Name="UserID" Location="CAMLVariable" DefaultValue="CurrentUserName"/&gt;

                        &lt;ParameterBinding Name="Today" Location="CAMLVariable" DefaultValue="CurrentDate"/&gt;

                        &lt;ParameterBinding Name="dvt_firstrow" Location="Postback;Connection"/&gt;

                        &lt;ParameterBinding Name="dvt_nextpagedata" Location="Postback;Connection"/&gt;

                    </property>

<property name="PageSize" type="int">1</property>

<property name="TitleUrl" type="string" />

<property name="ViewFlag" type="string">0</property>

<property name="Xsl" type="string">

 

 

&lt;xsl:stylesheet xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ddw1="http://www.webserviceX.NET/" version="1.0" exclude-result-prefixes="xsl msxsl ddwrt" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:ddwrt2="urn:frontpage:internal"&gt;

    &lt;xsl:output method="html" indent="no"/&gt;

    &lt;xsl:decimal-format NaN=""/&gt;

    &lt;xsl:param name="dvt_apos"&gt;&amp;apos;&lt;/xsl:param&gt;

    &lt;xsl:param name="dvt_firstrow"&gt;1&lt;/xsl:param&gt;

    &lt;xsl:param name="dvt_nextpagedata" /&gt;

    &lt;xsl:variable name="dvt_1_automode"&gt;0&lt;/xsl:variable&gt;

    

    &lt;xsl:template match="/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ddw1="http://www.webserviceX.NET/" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:SharePoint="Microsoft.SharePoint.WebControls"&gt;

        &lt;xsl:call-template name="dvt_1"/&gt;

    &lt;/xsl:template&gt;

    

    &lt;xsl:template name="dvt_1"&gt;

        &lt;xsl:variable name="dvt_StyleName"&gt;RepForm3&lt;/xsl:variable&gt;

        &lt;xsl:variable name="Rows" select="/soap:Envelope/soap:Body/ddw1:GetQuoteResponse"/&gt;

        &lt;xsl:variable name="dvt_RowCount" select="count($Rows)" /&gt;

        &lt;xsl:variable name="RowLimit" select="1" /&gt;

        &lt;xsl:variable name="FirstRow" select="$dvt_firstrow" /&gt;

        &lt;xsl:variable name="LastRow"&gt;

            &lt;xsl:choose&gt;

                &lt;xsl:when test="($FirstRow + $RowLimit - 1) &amp;gt; $dvt_RowCount"&gt;&lt;xsl:value-of select="$dvt_RowCount" /&gt;&lt;/xsl:when&gt;

                &lt;xsl:otherwise&gt;&lt;xsl:value-of select="$FirstRow + $RowLimit - 1" /&gt;&lt;/xsl:otherwise&gt;

            &lt;/xsl:choose&gt;

        &lt;/xsl:variable&gt;

        &lt;xsl:variable name="IsEmpty" select="$dvt_RowCount = 0" /&gt;

        &lt;table border="0" width="100%"&gt;

            &lt;xsl:call-template name="dvt_1.body"&gt;

                &lt;xsl:with-param name="Rows" select="$Rows[position() &amp;gt;= $FirstRow and position() &amp;lt;= $LastRow]"/&gt;

                &lt;xsl:with-param name="FirstRow" select="1" /&gt;

                &lt;xsl:with-param name="LastRow" select="$dvt_RowCount" /&gt;

            &lt;/xsl:call-template&gt;

        &lt;/table&gt;

        &lt;xsl:call-template name="dvt_1.commandfooter"&gt;

            &lt;xsl:with-param name="FirstRow" select="$FirstRow" /&gt;

            &lt;xsl:with-param name="LastRow" select="$LastRow" /&gt;

            &lt;xsl:with-param name="RowLimit" select="$RowLimit" /&gt;

            &lt;xsl:with-param name="dvt_RowCount" select="$dvt_RowCount" /&gt;

            &lt;xsl:with-param name="RealLastRow" select="number(ddwrt:NameChanged('',-100))" /&gt;

        &lt;/xsl:call-template&gt;

    &lt;/xsl:template&gt;

    &lt;xsl:template name="dvt_1.body"&gt;

        &lt;xsl:param name="Rows"/&gt;

        &lt;xsl:param name="FirstRow" /&gt;

        &lt;xsl:param name="LastRow" /&gt;

        &lt;xsl:for-each select="$Rows"&gt;

            &lt;xsl:variable name="dvt_KeepItemsTogether" select="false()" /&gt;

            &lt;xsl:variable name="dvt_HideGroupDetail" select="false()" /&gt;

            &lt;xsl:if test="(position() &amp;gt;= $FirstRow and position() &amp;lt;= $LastRow) or $dvt_KeepItemsTogether"&gt;

                &lt;xsl:if test="not($dvt_HideGroupDetail)" ddwrt:cf_ignore="1"&gt;

                    &lt;xsl:call-template name="dvt_1.rowview" /&gt;

                &lt;/xsl:if&gt;

            &lt;/xsl:if&gt;

        &lt;/xsl:for-each&gt;

        

    &lt;/xsl:template&gt;

    &lt;xsl:template name="dvt_1.rowview"&gt;

        &lt;tr&gt;

            &lt;td&gt;&lt;xsl:value-of select="concat(substring-before(substring-after(ddw1:GetQuoteResult,'&amp;lt;Name&amp;gt;'),'&amp;lt;/Name&amp;gt;'),' (',substring-before(substring-after(ddw1:GetQuoteResult,'&amp;lt;Symbol&amp;gt;'),'&amp;lt;/Symbol&amp;gt;'),')')" /&gt;&lt;/td&gt;

        &lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;table border="0" cellspacing="0" width="100%"&gt;&lt;tr&gt;&lt;td class="ms-vb" style="width: 60%"&gt;&lt;xsl:text xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" ddwrt:nbsp-preserve="yes" disable-output-escaping="yes"&gt;&amp;amp;nbsp;&lt;/xsl:text&gt;

            &lt;strong&gt;As Of:&lt;/strong&gt;&lt;/td&gt;&lt;td width="75%" class="ms-vb"&gt;&lt;xsl:value-of select="concat(

substring-before(substring-after(ddw1:GetQuoteResult,'&amp;lt;Time&amp;gt;'),'&amp;lt;/Time&amp;gt;'),' ',

substring-before(substring-after(ddw1:GetQuoteResult,'&amp;lt;Date&amp;gt;'),'&amp;lt;/Date&amp;gt;'))" /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr class="ms-searchimage"&gt;&lt;td class="ms-vb" style="width: 60%"&gt;&lt;strong&gt;Last:&lt;/strong&gt;&lt;/td&gt;&lt;td width="75%" class="ms-vb"&gt;&lt;xsl:value-of select="substring-before(substring-after(ddw1:GetQuoteResult,'&amp;lt;Last&amp;gt;'),'&amp;lt;/Last&amp;gt;')" /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="ms-vb" style="width: 60%"&gt;&lt;strong&gt;Change:

            &lt;xsl:text xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" ddwrt:nbsp-preserve="yes" disable-output-escaping="yes"&gt;&amp;amp;nbsp;&lt;/xsl:text&gt;

&lt;/strong&gt;&lt;/td&gt;&lt;td width="75%" class="ms-vb"&gt;&lt;xsl:value-of select="substring-before(substring-after(ddw1:GetQuoteResult,'&amp;lt;Change&amp;gt;'),'&amp;lt;/Change&amp;gt;')" /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr class="ms-searchimage"&gt;&lt;td class="ms-vb" style="width: 60%"&gt;&lt;strong&gt;Open:&lt;/strong&gt;&lt;/td&gt;&lt;td width="75%" class="ms-vb"&gt;&lt;xsl:value-of select="substring-before(substring-after(ddw1:GetQuoteResult,'&amp;lt;Open&amp;gt;'),'&amp;lt;/Open&amp;gt;')" /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="ms-vb" style="width: 60%"&gt;&lt;strong&gt;Low:&lt;/strong&gt;&lt;/td&gt;&lt;td width="75%" class="ms-vb"&gt;&lt;span&gt;&lt;xsl:value-of select="substring-before(substring-after(ddw1:GetQuoteResult,'&amp;lt;Low&amp;gt;'),'&amp;lt;/Low&amp;gt;')" /&gt;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;

            &lt;xsl:if test="$dvt_1_automode = '1'" ddwrt:cf_ignore="1"&gt;

                        &lt;tr&gt;

                            &lt;td colspan="99" class="ms-vb"&gt;

                                &lt;span ddwrt:amkeyfield="" ddwrt:amkeyvalue="string($XPath)" ddwrt:ammode="view"&gt;&lt;/span&gt;

                            &lt;/td&gt;

                        &lt;/tr&gt;&lt;/xsl:if&gt;

            &lt;tr class="ms-searchimage"&gt;&lt;td class="ms-vb" style="width: 60%"&gt;&lt;strong&gt;High

                &lt;xsl:text xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" ddwrt:nbsp-preserve="yes" disable-output-escaping="yes"&gt;&amp;amp;nbsp;&lt;/xsl:text&gt;

                &lt;/strong&gt;&lt;/td&gt;&lt;td width="75%" class="ms-vb"&gt;&lt;xsl:value-of select="substring-before(substring-after(ddw1:GetQuoteResult,'&amp;lt;High&amp;gt;'),'&amp;lt;/High&amp;gt;')" /&gt;&lt;/td&gt;&lt;/tr&gt;

            &lt;tr&gt;&lt;td class="ms-vb" style="width: 60%"&gt;&lt;strong&gt;Volume:

                &lt;xsl:text xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" ddwrt:nbsp-preserve="yes" disable-output-escaping="yes"&gt;&amp;amp;nbsp;&lt;/xsl:text&gt;&lt;/strong&gt;&lt;/td&gt;&lt;td width="75%" class="ms-vb"&gt;&lt;xsl:value-of select="substring-before(substring-after(ddw1:GetQuoteResult,'&amp;lt;Volume&amp;gt;'),'&amp;lt;/Volume&amp;gt;')" /&gt;&lt;/td&gt;&lt;/tr&gt;

            &lt;tr class="ms-searchimage"&gt;&lt;td class="ms-vb" style="width: 60%"&gt;&lt;strong&gt;Market Cap:

                &lt;xsl:text xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" ddwrt:nbsp-preserve="yes" disable-output-escaping="yes"&gt;&amp;amp;nbsp;

                

                &lt;/xsl:text&gt;&lt;/strong&gt;&lt;/td&gt;&lt;td width="75%" class="ms-vb"&gt;&lt;xsl:value-of select="substring-before(substring-after(ddw1:GetQuoteResult,'&amp;lt;MktCap&amp;gt;'),'&amp;lt;/MktCap&amp;gt;')" /&gt;&lt;/td&gt;&lt;/tr&gt;

            &lt;tr&gt;&lt;td class="ms-vb" style="width: 60%"&gt;&lt;strong&gt;Previous Close:&lt;/strong&gt;

                &lt;xsl:text xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" ddwrt:nbsp-preserve="yes" disable-output-escaping="yes"&gt;&amp;amp;nbsp;

                

                &lt;/xsl:text&gt;&lt;/td&gt;&lt;td width="75%" class="ms-vb"&gt;&lt;xsl:value-of select="substring-before(substring-after(ddw1:GetQuoteResult,'&amp;lt;PreviousClose&amp;gt;'),'&amp;lt;/PreviousClose&amp;gt;')" /&gt;&lt;/td&gt;&lt;/tr&gt;

            &lt;tr class="ms-searchimage"&gt;&lt;td class="ms-vb" style="width: 60%"&gt;&lt;strong&gt;Percentage Change:&lt;/strong&gt;

                &lt;xsl:text xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" ddwrt:nbsp-preserve="yes" disable-output-escaping="yes"&gt;&amp;amp;nbsp;

                

                &lt;/xsl:text&gt;&lt;/td&gt;&lt;td width="75%" class="ms-vb"&gt;&lt;xsl:value-of select="substring-before(substring-after(ddw1:GetQuoteResult,'&amp;lt;PercentageChange&amp;gt;'),'&amp;lt;/PercentageChange&amp;gt;')" /&gt;&lt;/td&gt;&lt;/tr&gt;

            &lt;tr&gt;&lt;td class="ms-vb" style="width: 60%"&gt;&lt;strong&gt;12 Month Range:&lt;/strong&gt;&lt;/td&gt;&lt;td width="75%" class="ms-vb"&gt;&lt;xsl:value-of select="substring-before(substring-after(ddw1:GetQuoteResult,'&amp;lt;AnnRange&amp;gt;'),'&amp;lt;/AnnRange&amp;gt;')" /&gt;&lt;/td&gt;&lt;/tr&gt;

            &lt;tr class="ms-searchimage"&gt;&lt;td class="ms-vb" style="width: 60%"&gt;&lt;strong&gt;Earnings Per Share:&lt;/strong&gt;

                &lt;xsl:text xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" ddwrt:nbsp-preserve="yes" disable-output-escaping="yes"&gt;&amp;amp;nbsp;

                

                &lt;/xsl:text&gt;&lt;/td&gt;&lt;td width="75%" class="ms-vb"&gt;&lt;xsl:value-of select="substring-before(substring-after(ddw1:GetQuoteResult,'&amp;lt;Earns&amp;gt;'),'&amp;lt;/Earns&amp;gt;')" /&gt;&lt;/td&gt;&lt;/tr&gt;

            &lt;tr&gt;&lt;td class="ms-vb" style="width: 60%"&gt;&lt;strong&gt;P-E:

                &lt;xsl:text xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" ddwrt:nbsp-preserve="yes" disable-output-escaping="yes"&gt;&amp;amp;nbsp;&lt;/xsl:text&gt;&lt;/strong&gt;&lt;/td&gt;&lt;td width="75%" class="ms-vb"&gt;&lt;xsl:value-of select="substring-before(substring-after(ddw1:GetQuoteResult,'&amp;lt;P-E&amp;gt;'),'&amp;lt;/P-E&amp;gt;')" /&gt;&lt;/td&gt;&lt;/tr&gt;

            &lt;/table&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/xsl:template&gt;

    &lt;xsl:template name="dvt_1.commandfooter"&gt;

        &lt;xsl:param name="FirstRow" /&gt;

        &lt;xsl:param name="LastRow" /&gt;

        &lt;xsl:param name="RowLimit" /&gt;

        &lt;xsl:param name="dvt_RowCount" /&gt;

        &lt;xsl:param name="RealLastRow" /&gt;

        &lt;table cellspacing="0" cellpadding="4" border="0" width="100%"&gt;

            &lt;tr&gt;

                &lt;xsl:if test="$FirstRow &amp;gt; 1 or $LastRow &amp;lt; $dvt_RowCount"&gt;

                    &lt;xsl:call-template name="dvt_1.navigation"&gt;

                        &lt;xsl:with-param name="FirstRow" select="$FirstRow" /&gt;

                        &lt;xsl:with-param name="LastRow" select="$LastRow" /&gt;

                        &lt;xsl:with-param name="RowLimit" select="$RowLimit" /&gt;

                        &lt;xsl:with-param name="dvt_RowCount" select="$dvt_RowCount" /&gt;

                        &lt;xsl:with-param name="RealLastRow" select="$RealLastRow" /&gt;

                    &lt;/xsl:call-template&gt;

                &lt;/xsl:if&gt;

            &lt;/tr&gt;

        &lt;/table&gt;

    &lt;/xsl:template&gt;

    &lt;xsl:template name="dvt_1.navigation"&gt;

        &lt;xsl:param name="FirstRow" /&gt;

        &lt;xsl:param name="LastRow" /&gt;

        &lt;xsl:param name="RowLimit" /&gt;

        &lt;xsl:param name="dvt_RowCount" /&gt;

        &lt;xsl:param name="RealLastRow" /&gt;

        &lt;xsl:variable name="PrevRow"&gt;

            &lt;xsl:choose&gt;

                &lt;xsl:when test="$FirstRow - $RowLimit &amp;lt; 1"&gt;1&lt;/xsl:when&gt;

                &lt;xsl:otherwise&gt;

                    &lt;xsl:value-of select="$FirstRow - $RowLimit" /&gt;

                &lt;/xsl:otherwise&gt;

            &lt;/xsl:choose&gt;

        &lt;/xsl:variable&gt;

        &lt;xsl:variable name="LastRowValue"&gt;

            &lt;xsl:choose&gt;

                &lt;xsl:when test="$LastRow &amp;gt; $RealLastRow"&gt;

                    &lt;xsl:value-of select="$LastRow"&gt;&lt;/xsl:value-of&gt;

                &lt;/xsl:when&gt;

                &lt;xsl:otherwise&gt;

                    &lt;xsl:value-of select="$RealLastRow"&gt;&lt;/xsl:value-of&gt;

                &lt;/xsl:otherwise&gt;

            &lt;/xsl:choose&gt;

        &lt;/xsl:variable&gt;

        &lt;xsl:variable name="NextRow"&gt;

            &lt;xsl:value-of select="$LastRowValue + 1"&gt;&lt;/xsl:value-of&gt;

        &lt;/xsl:variable&gt;

        &lt;td nowrap="nowrap" class="ms-paging" align="right"&gt;

            &lt;xsl:if test="$dvt_firstrow &amp;gt; 1" ddwrt:cf_ignore="1"&gt;

                &lt;a&gt;

                &lt;xsl:attribute name="href"&gt;javascript: &lt;xsl:value-of select="ddwrt:GenFireServerEvent('dvt_firstrow={1}')" /&gt;;&lt;/xsl:attribute&gt;

                Start&lt;/a&gt;

                &lt;xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes"&gt;&amp;amp;nbsp;&lt;/xsl:text&gt;

                &lt;a&gt;

                &lt;xsl:attribute name="href"&gt;javascript: &lt;xsl:value-of select="ddwrt:GenFireServerEvent(concat('dvt_firstrow={',$PrevRow,'}'))" /&gt;;&lt;/xsl:attribute&gt;

                &lt;img src="/_layouts/images/prev.gif" border="0" alt="Previous" /&gt;

                &lt;/a&gt;

                &lt;xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes"&gt;&amp;amp;nbsp;&lt;/xsl:text&gt;

            &lt;/xsl:if&gt;

            &lt;xsl:value-of select="$FirstRow" /&gt;

             - &lt;xsl:value-of select="$LastRowValue" /&gt;

            &lt;xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes"&gt;&amp;amp;nbsp;&lt;/xsl:text&gt;

            &lt;xsl:if test="$LastRowValue &amp;lt; $dvt_RowCount or string-length($dvt_nextpagedata)!=0" ddwrt:cf_ignore="1"&gt;

                &lt;a&gt;

                &lt;xsl:attribute name="href"&gt;javascript: &lt;xsl:value-of select="ddwrt:GenFireServerEvent(concat('dvt_firstrow={',$NextRow,'}'))" /&gt;;&lt;/xsl:attribute&gt;

                &lt;img src="/_layouts/images/next.gif" border="0" alt="Next" /&gt;

                &lt;/a&gt;

            &lt;/xsl:if&gt;

        &lt;/td&gt;

    &lt;/xsl:template&gt;

&lt;/xsl:stylesheet&gt;    </property>

<property name="NoDefaultStyle" type="string">TRUE</property>

<property name="Direction" type="direction">NotSet</property>

<property name="UseSQLDataSourcePaging" type="bool">True</property>

<property name="ListName" type="string" null="true" />

<property name="Hidden" type="bool">False</property>

<property name="DisplayName" type="string" />

<property name="SampleData" type="string" null="true" />

<property name="HelpUrl" type="string" />

<property name="ChromeType" type="chrometype">BorderOnly</property>

<property name="CatalogIconImageUrl" type="string" />

<property name="Height" type="string" />

<property name="DataFields" type="string">ddw1:GetQuoteResult,GetQuoteResult;</property>

<property name="Default" type="string" />

<property name="ChromeState" type="chromestate">Normal</property>

<property name="DataSourceID" type="string" />

<property name="AllowClose" type="bool">True</property>

<property name="CacheXslTimeOut" type="int">86400</property>

<property name="AllowMinimize" type="bool">True</property>

<property name="AllowEdit" type="bool">True</property>

<property name="XslLink" type="string" null="true" />

<property name="Title" type="string">Stock Ticker</property>

<property name="Width" type="string" />

<property name="ShowWithSampleData" type="bool">False</property>

<property name="ExportMode" type="exportmode">All</property>

<property name="AllowHide" type="bool">True</property>

<property name="AllowConnect" type="bool">True</property>

</properties>

</data>

</webPart>

</webParts>

 

--Michael

Comments

doesn't work

sorry doesn't work
at 3/11/2008 11:19 AM

More detail please.

Will,
Can you provide more detail?  Do you get an error message?
--Michael
Michael Blumenthal at 3/11/2008 7:17 PM

Have you checked your link show this webpart...

Have you checked your link show this webpart...

Point 4. Add (import) the web part to a web part zone on a web part page in a SharePoint site. When you are done, it should look like this.

Have you seen it...its really not working.

can you give me any solution???

Kuldeep
at 3/17/2008 10:12 PM

Worked Perfectly

Worked Great! Thanks
at 3/18/2008 11:41 AM

Kuldeep, it works for me

It works on my test page, http://blumenthalit.net/Files/StockQuote.aspx, and it worked for another person.  Therefore, as long as your server has access to the web service, it should work for you.  What error do you get?
--Michael
Michael Blumenthal at 3/19/2008 1:46 PM

Followed steps and received error

I followed the exact steps outlined and I still received an error.

I'm receiving the following message: "The server received a non-specific error when trying to get data from the data source.  Check the format and content of your query and try again.  If the problem persists..."

at 3/19/2008 1:52 PM

Debugging Steps

Can you get to http://www.webservicex.net/stockquote.asmx/GetQuote?symbol=msft from a web browser on the SharePoint server?

Does it work if you don't change the ticker symbol? Instead of copying and pasting the xml that is the webpart, if you use the option to save the file at http://blumenthalit.net/Files/DataViewWebPart_Stock_Ticker.webpart.txt and use that for the content of the webaprt file, does it work better?

Are you using WSS 3.0 or MOSS 2007 or are you using an earlier version?  I've only tested this with MOSS 2007 and WSS 3.0.

If these suggestions help, please let me know.

-Michael
Michael Blumenthal at 3/19/2008 2:03 PM

Debugging Steps Reply

Thanks for responding so quickly.

No, I can not access http://www.webservicex.net/stockquote.asmx/GetQuote?symbol=msft from my sharepoint server.  That server is configured to not allow for external internet access.

That is probably my 'crutch'.  That probably explains why I can't perform some other web service tasks that I've tried and failed at.

Thanks for the information and helping to resolve many of my other problems.
at 3/19/2008 2:30 PM

Multiple Stocks

How would one go about setting this up for multiple stocks?
at 3/27/2008 10:54 AM

This worked perfectly!

Thank you so much...

Can you tell me how to get the A in As Of: one space to the left?  I can't seem to force it over to the left margin.

Also, is there a way to show two columns of information instead of just one?  We look at another symbol and that would be very helpful.
at 3/27/2008 10:52 PM

RE: Multiple Stocks

The web service involved only takes a single stock symbol as a parameter.  If you want to have a web part that displays multiple ticker symbols, you will need to look elsewhere.  Note however that you can use multiple web parts on a page, so you could do it that way. Alternately, you should be able to use Web Part Connections to feed a ticker symbol from another web part to this web part.  For example, the other web part could be showing a list of ticker symbols, and selecting a symbol from that list could feed it to this web part.
Michael Blumenthal at 3/31/2008 9:08 AM

Regarding As Of and two columns

Regarding As Of, it's got to be in this chunk of XML somewhere:
------(ddw1:GetQuoteResult,'&amp;lt;Symbol&amp;gt;'),'&amp;lt;/Symbol&amp;gt;'),')')" /&gt;&lt;/td&gt;

        &lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;table border="0" cellspacing="0" width="100%"&gt;&lt;tr&gt;&lt;td class="ms-vb" style="width: 60%"&gt;&lt;xsl:text xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" ddwrt:nbsp-preserve="yes" disable-output-escaping="yes"&gt;&amp;amp;nbsp;&lt;/xsl:text&gt;

            &lt;strong&gt;As Of:&lt;/strong&gt;&lt;/td&gt;&lt;td width="75%" class="ms-vb"&gt;&lt;xsl:value-of select="concat(

------
It could be the blank line before &lt;strong&gt;As .  HTML can render carriage returns as spaces...

Regarding two columns, I think your best bet might be to put a second dataview web part right next to the first one, in the same web part zone, with horizontal layout, You could have one web part just display the field names, and then two to the left of it where each one would just display the values.  I am not sure how that would look, off the top of my head.
Michael Blumenthal at 3/31/2008 9:17 AM

Unable to display this Web Part.

Hello,

I deployed the web part and am getting this error :

 Unable to display this Web Part. To troubleshoot the problem, open this Web page in a Windows SharePoint Services-compatible HTML editor such as Microsoft Office SharePoint Designer. If the problem persists, contact your Web server administrator.
 
 I checked and I can browse to the web service from the WFE's. Also, I deployed it on my dev server and some teamsites and it works.

Any ideas would be appreciated.
at 4/8/2008 3:52 PM

Re: Web part not working on one server, but works on dev and some teamsites (4/8@3:52p)

Well, if it works in some of your environments but not others, and you are using the exact same web part file in all cases, then it's probably something specific to those environments, in which case I can't help you....
Sorry,
Michael

PS, For what it's worth, the Dataview Web Part doesn't appear to give me any control over error handling.  If there is some better way to debug this, specific to the data view web part, Dustin Milller would likely know - http://www.sharepointblogs.com/dustin/default.aspx.  He's pretty much THE expert when it comes to dataview web parts.

--Michael
Michael Blumenthal at 4/18/2008 7:13 AM

How to Simplify?

Love the part , works great but we don't need all the "extra" information. How can a non coder remove xml segments to only show:
As of
Last
change
% change
at 4/28/2008 11:33 AM

Time is off - est cst

I noticed the time appears to be off by an Hour as I'm in CST and it relating the quote after my current time less the 15-20 min delay. Can this be fixed? how?
at 4/28/2008 12:07 PM

Re: Simplify, Time Zone, and a note

Regarding Simplification:
You coudl just comment out (using <!-- and --> ) the appropriate XML, but looking at the XML in the .webpart file, it's awful hard (unless you are REALLY good at XSLT, which I am not yet), to see where one line of output ends and another begins.  Therefore, the less technical approach would be to open the page in SharePoint Designer and highlight the lines you don't want and just delete them.  If SharePoint Designer is still too technical, then you will have to wait for someone to make those changes and post their version.  I might if I have free time, but no promises.

Regarding Time Zone:
The quote time comes from the output of the web service, and I believe it's in ET because it represents a stock on the New York Stock Exchange.  The simplest solution is to simply add the "ET" time zone symbol next to the date.  My guess is that you could put it in here:
'&amp;lt;/Date&amp;gt;'))" /&gt;&lt;/td&gt;&
like this:
'&amp;lt;/Date&amp;gt;'))" /&gt;ET&lt;/td&gt;&  but I would have to test that to make sure.
Of course, doing that in SharePoint Designer would be a lot easier.
Alternatively, you could possibly wrap a function around the quote time to convert it to another time zone.  This is also easiest in SharePoint Designer.

And finally:
I've finally put this code under source control, on codeplex:
http://www.codeplex.com/SharePointStockQuote
so anyone who wants to contribute changes can.

--Michael
Michael Blumenthal at 4/29/2008 5:27 AM

Date and Time not refreshing

Hi Michael--
Great WebPart--it works wonderfully.
However, the date and time don't seem to be refreshing?
Is there any way to have the date and time on the stock quote part refresh every 15 mins or so.
at 5/9/2008 10:21 AM

Re: Date and Time Not Refreshing

You are correct - all of the data displayed is loaded when the page loads.  To get newere data, you need to refresh the page.  There are several ways to do this - you can give the user a button to reload the page, or add a link to refresh the web page at the bottom of the web part (note that the whole page would refresh), or add script that reloads the page every so often.  Note that after the market closes, the numbers don't change until the market opens the following day.
Michael Blumenthal at 5/9/2008 11:42 AM

Another thought about Refreshing the stock quote data

You could do another implementation all together that just uses Javascript (inside a content editor web part, for example), and uses XMLHTTP (i.e. a client side call) to call the web service.  You could then have the javascript run in a loop or on a timer event and dynamically update the displayed HTML on every interval/event.
Michael Blumenthal at 5/9/2008 11:45 AM

Ticker not working on your site nor mine?

My ticker stopped working a few days ago and I noticed the same on your site. Is the target provider experiencing issue?

p.s. thank you for your previous responses, better than some blog lag times.
at 5/27/2008 8:10 AM

WebServiceX.NET Stock Quote Web Service is Broken

If you go to the website for the stock quote web service, and test the service there, it throws an exception. 
For example, if you go to http://www.webservicex.net/stockquote.asmx?op=GetQuote and try it with a stock ticker symbol such as MSFT,  it returns an exception:
  <?xml version="1.0" encoding="utf-8" ?>
  <string xmlns="http://www.webserviceX.NET/">exception</string>

Therefore, the dataview web part has no data to work with and you get unexpected results.

The contact form on the WebServiceX.net site is broken, and email to support at webservicex.net bounces, and "Real Time Market Data" is listed as Unavailable on their support page at http://www.webservicex.net/WCF/Support.aspx .

Based on that, I would not consider it likely that this issue will be resolved anytime soon.  Can anyone find another free provider of this data?

--Michael
Michael Blumenthal at 5/27/2008 9:05 AM

Excellent job

Hi,
 I just found this today and it is great. Perfect for our companies site, and I was able to trim it down a bit with SPD 2007.
at 7/11/2008 9:05 AM

Excellent job

Hi,
 I just found this today and it is great. Perfect for our companies site, and I was able to trim it down a bit with SPD 2007.
at 7/11/2008 9:20 AM

I'm having an error too

I'm getting an error.  It works when I go to another page but whenever I go to do it on my own site there is this error:

Cannot recognize the XML namespace of this Web Part.

I haven't changed anything but I still get the error.
at 7/17/2008 12:34 PM

Re: XML Namespace issue

No idea.  Mine still works (http://blumenthalit.net/Files/StockQuote.aspx).
Did you accidentally change the xml in the .webpart file in some way other than changing the ticker symbol?
Michael Blumenthal at 7/23/2008 8:53 AM

SWEET!!

Very Nice - worked in less than 5!!  :)
at 8/22/2008 8:24 AM

WebServiceX.NET Stock Quote Web Service is Broken - Working Intermittently

It seems that the WebServiceX.NET Stock Quote Web Service is working intermittently. 

Sometimes It works but other times, I am seeing an error message that says "Unable to Display  this WebPart, To troubleshoot the Problem, Open this web page with a SharePoint Services-Compatible HTML Editor such as Microsoft SharePoint Designer. If the Problem Persisits, Contact your Web Administrator." 

Anyone one else experiencing this problem or know how it can be resolved?  Any ideas?

Secondly, when the Stock Quote is working, it slows down opening of the intranet site since it is installed on the home page.  Is there anyway to speed up opening of the homepage that has the stock quote webpart?
at 9/18/2008 12:46 PM

WebServiceX.NET Stock Quote Web Service is Broken - Working Intermittently

It seems that the WebServiceX.NET Stock Quote Web Service is working intermittently. 

Sometimes It works but other times, I am seeing an error message that says "Unable to Display  this WebPart, To troubleshoot the Problem, Open this web page with a SharePoint Services-Compatible HTML Editor such as Microsoft SharePoint Designer. If the Problem Persisits, Contact your Web Administrator." 

Anyone one else experiencing this problem or know how it can be resolved?  Any ideas?

Secondly, when the Stock Quote is working, it slows down opening of the intranet site since it is installed on the home page.  Is there anyway to speed up opening of the homepage that has the stock quote webpart?
at 9/18/2008 2:37 PM

Re: WebServiceX.NET Stock Quote Web Service is Broken - Working Intermittently

Since we have no control over how WebserviceX.net runs their service, and since it's free, we have no guarantee of performance on their part. Here are some suggestions:
1) Find a different web service provider.  The Data View Web Part can be used to hook up to almost any web service.  This is essentially re-creating the web part in SharePoint Designer.
2) Regarding the complaint that it slows down the load of the home page:
a) If you have this on a MOSS site with publishing features turned on, does changing the Output Cache settings for the site or site collection help?
b) You could have a proxy server cache the call to the web service.
c) You could build your own web part (e.g. in Visual Studio)that implements caching and talks to a more reliable provider.
d) You could buy a web part that provides these features.  I don't know if the web part from Data Springs provides caching or not, nor what its performance characteristics are.

Hope that helps.
--Michael
Michael Blumenthal at 9/19/2008 6:34 AM

Stock Quote Web Part Slows down load on Home Page

I have the same issue.  Thanks for your tips.  I have a question though.  I would like to see if I can implement caching on the web part to improve performance.  What are the steps of implementing caching on the web part.
at 9/21/2008 9:23 PM

Web Service Providers

Hi,

Do you have any suggestions on good stock quote web service providers that you would recommend ?
at 9/22/2008 7:03 AM

Creating a .Webpart file for Stock Quote WebPart

I have identified a different web service provider that provides stock quote web service.  The Provider has given us the WSDL URL on their website which we can use to discover the service.

I would like to be able to create a .WebPart file similar to the one posted on your blog i.e with the same formatting and same stock parameters.  Basically, I am looking to have exactly what you have posted here but the only difference will be that I will be using a different Web Service Provider.

I just wanted to see if you could give me the step by step process of creating a .Webpart file like the one you have here..that I would then easily import into my sharepoint site.  The Web Service provider is called Xignite and their site is xignite.com

Thankyou in advance.
at 9/23/2008 1:35 PM

PURSING THE XML BLOB

Thanks for the Info...Very Great Info !

Question....How did you use the substring-before and substring-after commands to parse the XML blob returned by the service.  What is the process of doing that in SharePoint Designer?

We are using a different web service provider. When we point the data view webpart to the WSDL URL, we get the XML Blob.

Do you have the code you used and the steps to do this so that we can duplicate.  Your help will be greatly appreciated.
at 9/25/2008 11:24 AM

Re: Free Stock Quote Web Part

Great Post...Worked within Minutes.

I have the same problem with Pursing the XML Blob as the comment above...Do you have the code you used and the steps to do it in Sharepoint designer?

Also, can anyone recommend other Web Service Providers that provide Stock Quotes?

Thanks
at 9/25/2008 8:27 PM

Responses to last serveral posts

How to implement caching in code: See http://support.microsoft.com/kb/323290 for a starting point.

Other stock quote vendors: Xignite (suggested in a comment by Rick above) looks like a stock quote vendor worth evaluating.  They offer a 100 quote trial which is plenty to set up a Dataview Web Part, but they do charge for their service.

As for how to parse the XML blog that you get back, I was basically using substring functions.  I suggest you go and watch Dustin Miller's video on the DVWP, as he demonstrates how to hook it up to a Yahoo weather XML blob.
There is a link to Dustin's webcast in the original post (http://blumenthalit.net/blog/Lists/Posts/Post.aspx?ID=29)

Regarding the substring-before and substring after comamnds:
If you have an xml chunk like:
<mytag>MSFT</mytag>
You can use substring-after to give you everything after the opening tag, and then you use substring-before to give you everything before the closing tag.  In other words, the call to substring-after is nested inside the call to substring-before.

Hope that helps.

--Michael
Michael Blumenthal at 9/26/2008 7:09 PM

How can i use the same webpart for multiple stock Quotes

Hi,

can any one help me how to use the same webpart for multiple stock quotes whic is my requirement

and it should be configurable , i need to display the 4 different stock quotes at a time
at 9/29/2008 1:54 PM

Using this web part for multiple stock quotes

This web part only displays one quote, however you can make several different versions of the .webpart file (each referencing a different ticker file). You can then upload each and place it on your web part page.  In other words, you can have multiple ticker symbols by having different versions of this web part sitting on your web part page.

--Michael
Michael Blumenthal at 9/29/2008 3:47 PM

how can i make it so the end user will enter the stock quotes symbol

hi,

how can i make it so the end user will enter the stock quotes symbol

and i should display the data related to that stock quotes symbol
at 9/30/2008 10:34 AM

if it dose not work

Hi,

Initially it did not work for me in my company network as my company network will authenticate all the request comming  from IE

and then afterwards i have tried in my non proxy network

it was working fine

Thanks a lot Michael
at 9/30/2008 12:40 PM

if it dose not work

Hi,

Initially it did not work for me in my company network as my company network will authenticate all the request comming  from IE

and then afterwards i have tried in my non proxy network

it was working fine

Thanks a lot Michael
at 9/30/2008 1:27 PM

if it dose not work

Hi,

Initially it did not work for me in my company network as my company network will authenticate all the request comming  from IE

and then afterwards i have tried in my non proxy network

it was working fine

Thanks a lot Michael
at 9/30/2008 1:42 PM

Stock Ticker Web Part

I recently ported Scott Vintinner's code for the Stock Ticker Web Part that allows each user to track their own stocks.  It uses Yahoo's Finance service and requires no signup or registration of your website.  I know Scott and I both would sure appreciate your feedback...

http://armsinfragilehands.blogspot.com/2008/10/scott-vintinners-stock-ticker-web-part.html
at 10/10/2008 8:47 AM

Hey

It just worked fine!!!!
at 3/18/2009 12:11 AM

Error when environment has AAM settings and connect using SSL-VPN

I have MOSS 2007 which is accessed by the users through SSL-VPN. So for allowing users to access the site smoothly I have to set the AAM-internet setting.

The moment I add internal URL (internet) in AAM the stock DVWP stops working. It shows the error "Unable to Display  this WebPart, To troubleshoot the Problem, Open this web page with a SharePoint Services-Compatible HTML Editor such as Microsoft SharePoint Designer. If the Problem Persisits, Contact your Web Administrator"

Also when I check the page by logging into the domain the stock value DVWP works perfectly.

Do you have any ideas why this is happening?

-MG2005
at 6/9/2009 4:04 PM

Re: MG2005

Sorry, no idea why it breaks. Hopefully, in SharePoint Designer 2010 we might get some sort of debugging capability for DVWP's, but that might not be realistic.
--Michael
Michael Blumenthal at 6/10/2009 10:14 PM

can anyone help me ?

i am currently trying to implement the webservicex.net/stockquote.asmx using C# and webparts etc... i have created a textbox for users to enter the stock quote(e.g. mcd, intc) and a button to retrieve the information.
Results are displayed using a Label. The problem i encountered is similar to a few of you guys and that is the data that is displayed is all clustered without any spacing etc... e.g. mcd9/25/200940.2     is there anyway i can display the data in a more readable format?

Ethan
at 9/29/2009 12:01 AM

Works great

Not sure why others are having difficulty, but this was so easy for me ... worked great, thanks!
at 10/12/2009 11:20 AM

Add Comment

Items on this list require content approval. Your submission will not appear in public views until approved by someone with proper rights. More information on content approval.

Title


Body *


Please put your name at the end of your comment as the Name field doesn't display in the main view of the comments.

Name: *


Your name.  If you first name is Michael, please provide initials or the like to clearly distinguish your name from Michael Blumenthal's.
Also, this field does not appear in the main view of the comments.

Need Paid Consulting Services?

Are you interested in engaging a SharePoint consultant for fee-based consulting services?  If so, I can have an Account Executive from my employer contact you.  Other site visitors will not see this column.

Additional Contact Information

Please provide additional contact information if you need a direct response.  Other site visitors will not see this column.

What is tomorrow's date? *

This is a weak CAPTCHA based on advice from a tweet from @ToddKlindt.
Attachments