Solved

The URI prefix is not recognized - XML Reader

Posted on 2011-09-19
6
3,734 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 30

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 30

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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 30

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 30

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

Use Filtering Commands to Process Files in Linux

Learn how to manipulate data with the help of various filtering commands such as `cat`, `fmt`, `pr`, and others in Linux.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
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 look for a specific file type in a local or remote server directory using PHP.
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…
Suggested Courses

624 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