home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2003 November
/
PCWorld_2003-11_cd.bin
/
Novinky
/
Interval
/
podklady
/
ruzicka
/
aspx
/
rss
/
rssreader
/
rssreader.ascx
< prev
next >
Wrap
Text File
|
2003-09-05
|
2KB
|
60 lines
<%@ Control Language="C#" EnableViewState="False" Debug="False" %>
<%@ OutputCache Duration="7200" Shared="True" VaryByControl="XmlParser1" %>
<%@ Import Namespace="System.Net" %>
<%@ Import Namespace="System.Xml" %>
<script language="C#" runat="server">
private string rssurl,rssxsl;
public string RssUrl
{
set { rssurl = value; }
}
public string RssXsl
{
set { rssxsl = value; }
}
XmlDocument getXML(string sourceURL)
{
try
{
WebRequest myRequest = WebRequest.Create(sourceURL);
WebResponse myResponse = myRequest.GetResponse();
XmlTextReader myReader = new XmlTextReader(myResponse.GetResponseStream());
XmlDocument doc = new XmlDocument();
doc.Load(myReader);
myResponse.Close();
myReader.Close();
return doc;
}
catch(WebException e)
{
return null;
}
catch(Exception e)
{
return null;
}
}
void Page_Init(object sender, System.EventArgs e)
{
if ((rssurl != null) && (rssxsl != null))
if ((rssurl != String.Empty) && (rssxsl != String.Empty))
if ((XmlParser1.Document = getXML(rssurl))!=null)
try
{
XmlParser1.TransformSource=rssxsl;
XmlParser1.Visible = true;
LblError.Visible = false;
}
catch (Exception ex)
{
LblError.Visible = true;
}
}
</script>
<asp:Xml Id="XmlParser1" Visible="false" RunAt="server" />
<asp:Label Id="LblError" Text="Seznam článků nelze načíst..." RunAt="server" />