<%@ Page Language="VB" %>
<%@ Import Namespace="System.Xml" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Collections" %>
<%@ Import Namespace="System.Net" %>
<%@ Import Namespace="System.IO" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<script language="vbscript" runat="server">
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Try
BindRSSFeeds("http://localhost/WebSite1/magazzino.xml")
Catch ex As Exception
'throw some error.
End Try
End Sub
Private Function GetXMLContent(ByVal ContentURL As String) As XmlReader
Try
Dim wr As HttpWebRequest = CType(WebRequest.Create(ContentURL), _
HttpWebRequest)
wr.Timeout = 10000 ' 10 seconds
Dim resp As WebResponse = wr.GetResponse()
Dim stream As stream = resp.GetResponseStream()
Dim reader As XmlTextReader = New XmlTextReader(stream)
reader.XmlResolver = Nothing
Return reader
Catch ex As Exception
'estione errore
End Try
End Function
Private Sub BindRSSFeeds(ByVal inURL As String)
Try
Dim myRSSFeed As New DataSet
myRSSFeed.ReadXml(GetXMLContent(inURL))
dataRSSItems.DataSource = myRSSFeed.Tables("item")
dataRSSItems.DataBind()
Catch ex As Exception
'gestione errore
End Try
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:DataList ID="dataRSSItems" Runat="server" RepeatLayout="Table"
AlternatingItemStyle-BackColor=AliceBlue
SelectedItemStyle-BackColor=#ffff00
RepeatDirection="Vertical" RepeatColumns="1">
<SelectedItemStyle BackColor="Yellow"></SelectedItemStyle>
<ItemTemplate>
<asp:LinkButton ID="btnTitle" CssClass="subsubhead"
Text='<%#Container.DataItem("nome")%>' Runat="server"
CommandName="select">
</asp:LinkButton>
<br>
<asp:Label Runat="server" ID="lblRssDescription"
CssClass="normal" Text='<%#Container.DataItem("quantita")%>'>
</asp:Label>
</ItemTemplate>
</asp:DataList>
</div>
</form>
</body>
</html>