Which way is better?

wxdqz

New Member
I've been working with XML data and ASP.NET web forms for the past couple of days, and developed a simple display page that pulls its data from an XML doc. You can see the page at <!-- m --><a class="postlink" href="http://www.douglas-county.com/test_folder/aspx/contacts.aspx">http://www.douglas-county.com/test_fold ... tacts.aspx</a><!-- m -->
(NOTE: I've included the actual code for the ASP.NET page and link to the XML doc at the end of this post)

Then I went to W3Schools's website again to see how they had done the same thing, and noticed that their solution was done in a completely different way by simply pulling the XML data along with an XSLT stylesheet in an "<asp:xml>" tag. You can see it at <!-- m --><a class="postlink" href="http://www.w3schools.com/aspnet/showasp.asp?filename=demo_xml">http://www.w3schools.com/aspnet/showasp ... e=demo_xml</a><!-- m -->

So my question is, which approach is better and more efficient for the user? Just from looking at the original code, it looks like the W3Schools approach is a better way to do things, and allows for more flexibility when it comes to creating XSLT stylesheets for different file formats. But I'd like to hear what others have to say. Thanks for any advice.

Contacts.aspx XML code:
<!-- m --><a class="postlink" href="http://www.douglas-county.com/test_folder/xml/contacts.xml">http://www.douglas-county.com/test_fold ... ntacts.xml</a><!-- m -->

Contacts.aspx ASP.NET code:
<%@ Page Language="VB" Debug="true" EnableSessionState="false" %>
<%@ import Namespace="System.Data" %>
<script runat="server">

Sub Page_Load
if Not Page.IsPostBack then
Dim myAN = New DataSet
myAN.ReadXml("http://www.douglas-county.com/test_folder/xml/contacts.xml")
dbAN.DataSource = myAN
dbAN.DataBind()

End if

End Sub

</script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Douglas County, Kansas - Contacts</title>
<link href=http://www.webdeveloper.com/forum/archive/index.php/"/scriptlibrary/stylesheet_dg.css" rel="stylesheet" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<form runat="server">
<p>
<asp:DataGrid id="dbAN" runat="server" AutoGenerateColumns="False" BorderWidth="0px" CellSpacing="1" CellPadding="1" Width="100%">
<AlternatingItemStyle backcolor="#CCCCCC"></AlternatingItemStyle>
<HeaderStyle font-bold="True" forecolor="White" backcolor="#330066"></HeaderStyle>
<Columns>
<asp:HyperLinkColumn DataNavigateUrlField="url" DataTextField="title" HeaderText="Department" NavigateUrl="url"></asp:HyperLinkColumn>
<asp:BoundColumn DataField="phone" HeaderText="Phone"></asp:BoundColumn>
<asp:BoundColumn DataField="fax" HeaderText="Fax"></asp:BoundColumn>
<asp:BoundColumn DataField="address" HeaderText="Address"></asp:BoundColumn>
<asp:BoundColumn DataField="hours" HeaderText="Office Hours"></asp:BoundColumn>
</Columns>
</asp:DataGrid>
</p>
</form>
</body>
</html>
 
Top