Solved

The URI prefix is not recognized - XML Reader

Posted on 2011-09-19
6
3,285 Views
Last Modified: 2013-11-18
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
Comment
Question by:JenebyM
  • 4
  • 2
6 Comments
 
LVL 29

Expert Comment

by:anarki_jimbel
ID: 36564427
Did you try to pass the uri without  'feed' or 'http'? Just:

www.rba.gov.au/rss/rss-cb-exchange-rates.xml
0
 
LVL 29

Expert Comment

by:anarki_jimbel
ID: 36564431
OK, ignore my comment...
0
 

Author Comment

by:JenebyM
ID: 36564438
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 29

Accepted Solution

by:
anarki_jimbel earned 500 total points
ID: 36564479
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
 

Author Closing Comment

by:JenebyM
ID: 36564514
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
 
LVL 29

Expert Comment

by:anarki_jimbel
ID: 36564563
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
The viewer will learn how to count occurrences of each item in an array.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

757 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

21 Experts available now in Live!

Get 1:1 Help Now