Working ASP.NET code
for using XML file as a Database
XML Code for emp.xml
file
<?xml version="1.0"
encoding="iso-8859-1"?>
<emp>
<record>
<name>Raja</name>
<age>25</age>
</record>
<record>
<name>Peter</name>
<age>23</age>
</record>
</emp>
ASP.NET
Code for
simpleRepeater.aspx
<%@ Import
Namespace="System.Data" %>
<script runat="server">
sub Page_Load
if Not Page.IsPostBack then
dim empDataSet=New DataSet
empDataSet.ReadXml(MapPath("emp.xml"))
empRepeater.DataSource=empDataSet
empRepeater.DataBind()
end if
end sub
</script>
<html>
<body>
<form runat="server">
<asp:Repeater id="empRepeater" runat="server">
<HeaderTemplate>
<table border="1" >
<tr>
<th align="left">Name</th>
<th align="left">Age</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td><%#Container.DataItem("name")%> </td>
<td><%#Container.DataItem("age")%> </td>
</tr>
</ItemTemplate>
|