Solved

The URI prefix is not recognized - XML Reader

Posted on 2011-09-19
6
3,452 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

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.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
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:
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

777 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