Solved

The URI prefix is not recognized - XML Reader

Posted on 2011-09-19
6
3,368 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

943 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

10 Experts available now in Live!

Get 1:1 Help Now