
XML and ASP.NET • 401
The resulting output is shown in Figure 8.9.
Figure 8.9 Effect of using XmlWriter
8.4 EXTRACTING DATA FROM A DATABASE AS AN XML
DOCUMENT
In ASP.NET, we can retrieve data from a traditional RDBMS directly as an XML document! This is useful
in situations where we want to be able to read the contents of a table directly as an XML document, so that
we can send it to another application.
The code for doing this is shown in Figure 8.10.
<%@PageLanguage=”C#”%>
<%@ Import Namespace =”System.Data” %>
<%@ Import Namespace =”System.Data.SqlClient” %>
<%@ImportNamespace=”System.Conguration”%>
<%@ Import Namespace = “System.Data.OleDb” ...