PDA

View Full Version : Newsfeed not connecting


SteveH
06-11-2008, 09:15 PM
Hello

I am trying to get a newsfeed to work on a test MX 2004 Flash site here:

http://stevehigham59.7host.com/feed/news.html

I have used the script from an online tutorial and changed only the xml link from Macromedia to the BBC.

I am getting a 'connect failed' error message and I'm not sure why. Here is the script:

<%@ Import NameSpace="System" %>
<%@ Import NameSpace="System.Net" %>
<%@ Import NameSpace="System.IO" %>
<%@ Import NameSpace="System.Text.RegularExpressions" %>
<script language="C#" runat="server">


string _path = "http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/technology/rss.xml";

public void Page_Load(Object sender, EventArgs e) {
getData(_path);
}

protected void getData(string url){

string _url = "";
string _urlAry = "";
string _desc = "";
string _descAry = "";
string _titleAry = "";

WebClient request = new WebClient();

Stream s = request.OpenRead(url);

StreamReader sr = new StreamReader(s);

Regex myRegex = new Regex(@"(<url>.*</url>)|(<title>.*</title>)");

MatchCollection mc = myRegex.Matches(sr.ReadToEnd());

foreach (Match m in mc){

if (m.Value.IndexOf("url") > 0){

_url = m.Value;

_url = _url.Replace("<url>","");
_url = _url.Replace("</url>","");

_urlAry += _url + "|";
} else {

_desc = m.Value;
_desc = _desc.Replace("<title>","");
_desc = _desc.Replace("</title>","");
_descAry += _desc + "|";
}
}

_descAry = _descAry.Substring(0,_descAry.Length-1);
_urlAry = _urlAry.Substring(0,_urlAry.Length-1);

Response.Write ("theUrls="+Server.UrlEncode(_urlAry)+"&theTitles="+Server.UrlEncode(_descAry));
}
</script>

I would be grateful for any help.

Steve

gnomeontherun
06-11-2008, 11:53 PM
This isn't asp...so I can't help you in this forum. Either put this in ASP, or put some actionscript here :)

SteveH
06-12-2008, 03:54 PM
OK, Jeremy, done

Steve