Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3976
  • Last Modified:

The URI prefix is not recognized - XML Reader

I have a pretty simple application that extracts exchange rates from an RSS feed and displays content on the Grid.

I keep getting the error "The URI prefix is not recognised"

Using "feed//" always generates this error. I tried using "http://". This works but that does not have the content that I need.

Help
using System;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml;

namespace eXtra.Pages
{
    public partial class CurrencyRSS : System.Web.UI.Page
    {
        /*The rate shown for the US dollar is a representative mid-point determined 
         * by the Reserve Bank on the basis of quotations in the interbank foreign 
         * exchange market at 4.00 pm Australian Eastern Standard Time on the day concerned.
         * Rates shown for most other currencies are calculated by crossing the rate for 
         * the US dollar with mid-points of buying and selling rates quoted at the same time.
         * These rates are indications of market value only and may differ from those quoted
         * by foreign exchange dealers.*/



        protected void Page_Load(object sender, EventArgs e)
        {
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            XmlTextReader rssReader = new XmlTextReader("feed://www.rba.gov.au/rss/rss-cb-exchange-rates.xml");
            DataSet ds = new DataSet();
            ds.ReadXml(rssReader);
            myCurrency.DataSource = ds;
            myCurrency.DataBind();
        }
    }
}


<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CurrencyRSS.aspx.cs" Inherits="eXtra.Pages.CurrencyRSS" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
  
    <asp:GridView ID="myCurrency" runat="server">
    </asp:GridView>
    <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
    </form>
</body>
</html>

Open in new window

0
JenebyM
Asked:
JenebyM
  • 4
  • 2
1 Solution
 
anarki_jimbelCommented:
Did you try to pass the uri without  'feed' or 'http'? Just:

www.rba.gov.au/rss/rss-cb-exchange-rates.xml
0
 
anarki_jimbelCommented:
OK, ignore my comment...
0
 
JenebyMAuthor Commented:
Using :

XmlTextReader rssReader = new XmlTextReader("www.rba.gov.au/rss/rss-cb-exchange-rates.xml");

returns the following error:

Could not find a part of the path 'C:\Program Files\Common Files\Microsoft Shared\DevServer\10.0\www.rba.gov.au\rss\rss-cb-exchange-rates.xml'.

Can't understand why this would be looking for the file on the DevServer.

Any more ideas?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
anarki_jimbelCommented:
OK, I'm trying to check. The thing is that your reader get ALL the information from the address:

"http://www.rba.gov.au/rss/rss-cb-exchange-rates.xml" Not yet sure why this information is not displayed in a grid. I believe because this content is not a table!

You may try to print the content into console or debug window:


XmlTextReader rssReader = new XmlTextReader(   "http://www.rba.gov.au/rss/rss-cb-exchange-rates.xml");

            // Skip non-significant whitespace  
            rssReader.WhitespaceHandling = WhitespaceHandling.Significant;  

            // Read nodes one at a time  
            while (rssReader.Read())
            {
                // Print out info on node  
                System.Diagnostics.Debug.WriteLine( rssReader.Value);
            }

Open in new window

0
 
JenebyMAuthor Commented:
This works and shows the content of the site. The content is not in table format.

Because I am not using a console apps, I have viewed the content using a string builder.

I have now been able to see the data. This helps me solve the problem. I actually need the data in xml format so I will use XML load to load the file and read the nodes in a structured way.

Thanks for solving my original problem
0
 
anarki_jimbelCommented:
OK, you need to parse your xml

Have a look at the example:
http://www.superiorwebsys.com/blog/34/How_to_parse_RSS_using_PHP_and_C

In your case you may need a namespace manager.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now