RSS feed in C# - get exchange rates

Posted on 2011-04-26
Last Modified: 2013-11-18
How do I get the exchange rate from this rss feed?

Void GetExchangeRate (string CurrencyCode, out Decimal ReturnRate, out DateTime ReturnDateTime)

//Do something...

//Return the Rate and DateTime

Question by:RobertChanphakeo
    LVL 1

    Expert Comment


    <MARQUEE  id="ml"  runat="server"  style="PADDING-TOP: 2px" onmouseover=" this.stop()" onmouseout=this.start() direction=right height=24 width="100%" scrollAmount=4><SPAN class=sep>¿¿¿¿¿¿¿.¿¿</SPAN></MARQUEE>
    Public Partial Class arabiaNews
        Inherits System.Web.UI.Page
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        End Sub
        Sub newsarabia()
            Dim ds As New Data.DataSet
            Dim strRss As String = Server.MapPath("Intranet/arabiaRss.xml")
            If ds.Tables.Count > 0 Then
                If ds.Tables(3).Rows.Count > 0 Then
                    For i As Integer = 0 To ds.Tables(3).Rows.Count - 1
                        Dim NewTitle As String = ds.Tables(3).Rows(i)("title")
                        Dim url As String = ds.Tables(3).Rows(i)("link")
                        Dim lnk As New HtmlAnchor 'With {.InnerHtml = NewTitle, .HRef = url, .Target = "_blank"}
                        lnk.InnerHtml = NewTitle
                        lnk.HRef = url
                        lnk.Target = "_blank"
                        ml.Controls.Add(New LiteralControl("&nbsp;&nbsp;&nbsp;"))
                End If
            End If
        End Sub
    End Class

    Open in new window

    LVL 11

    Expert Comment

    You could go the route of loading the response into an XDocument or XmlReader and parsing out what you need manually. Bu a better approach would be to use an RSS parser meant for the job.

    This is a good example of how to parse RSS feeds, you should be able to extract the required values easily using this: There are also links to other feebie RSS parsers if this simple one does not cater for your needs.
    LVL 10

    Accepted Solution

    You can use xPath, xQuery or Linq to xml for parsing purposes. Sample c# code using xPath would be like this:

    public static string GetRSSFeedDataSource(string url)
            XmlTextReader feedreader = null;
            XmlDocument feedDocument = null;
            string sFeedString = string.Empty;
                feedreader = new XmlTextReader(url);
                // Get basic feed document
                feedDocument = new XmlDocument();
                String sParsedValue = string.Empty;
                // Create a navigator to query with XPath.
                XPathNavigator nav = feedDocument.CreateNavigator();
                string namespaceUri = "";
                XmlNamespaceManager ns = new XmlNamespaceManager(new NameTable());
                ns.AddNamespace("ns", namespaceUri);
                    XPathNodeIterator iterator = nav.Select("/rdf", ns); // update xPath expression
                    foreach (XPathNavigator item in iterator)
                        // Get value for the selected expression
                        sParsedValue = item.Value;                    
                catch { }
            catch (Exception)
            return sFeedString;

    Open in new window

    I hope it helps.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Preface In the first article: A Better Website Login System ( I introduced the EE Collaborative Login System and its intended purpose. In this article I will discuss some of the design consideratio…
    Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
    Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
    Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now