Agência OFF, desenvolvimento de soluções web para as Agências Digitais
Aula baseada no site da w3schools
Código pronto para puxar informações de um arquivo XML, simples e prático!
Arquivo: RepeaterControl.xml
<?xml version="1.0" encoding="ISO-8859-1"?> <catalogo> <cd> <titulo>Empire Burlesque</titulo> <artista>Bob Dylan</artista> <ano>1985</ano> </cd> <cd> <titulo>Hide your heart</titulo> <artista>Bonnie Tyler</artista> <ano>1988</ano> </cd> <cd> <titulo>Greatest Hits</titulo> <artista>Dolly Parton</artista> <ano>1982</ano> </cd> <cd> <titulo>Still got the blues</titulo> <artista>Gary Moore</artista> <ano>1990</ano> </cd> <cd> <titulo>Eros</titulo> <artista>Eros Ramazzotti</artista> <ano>1997</ano> </cd> </catalogo>
Arquivo: RepeaterControl.aspx
<%@ Page Language="VB" Debug="True" Explicit="True" %>
<%@ Import NameSpace="System.Data" %>
<script runat="server">
Sub Page_Load
If Not Page.IsPostBack Then
Dim MeuCdCatalogo = New DataSet
MeuCdCatalogo.ReadXml (MapPath("RepeaterControl.xml"))
Catalogo.DataSource = MeuCdCatalogo
Catalogo.DataBind()
End If
End Sub
</script>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Repeater Control</title>
</head>
<body>
<form runat="server">
<asp:Repeater Id="Catalogo" runat="server">
<HeaderTemplate>
<table border="1" align="center" width="50%">
<tr>
<th>Título</th>
<th>Artista</th>
<th>Ano</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td><%# Container.DataItem("Titulo") %></td>
<td><%# Container.DataItem("Artista") %></td>
<td><%# Container.DataItem("Ano") %></td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
</form>
</body>
</html>
Acesse também: Webly
Agência OFF, desenvolvimento de soluções web para as Agências Digitais

