Mac os x web server - CHAPTER 12 CASE STUDY: USING .NET FOR

CHAPTER 12 CASE STUDY: USING .NET FOR AN XML APPLICATION 365 XMLFeed.WriteStartElement(”item”) XMLFeed.WriteElementString(”title”, dr(”newsTitle”).ToString()) XMLFeed.WriteElementString(”description”, dr(”newsDescription”).ToString()) XMLFeed.WriteEndElement() Next XMLFeed.WriteEndElement() XMLFeed.WriteEndElement() XMLFeed.WriteEndDocument() XMLFeed.Flush() XMLFeed.Close() Response.End() End sub This page doesn t use the master page, as it contains only XML content. The page starts by declaring the language and importing namespaces: <%@ Page Language="VB" %> <%@ import Namespace="System.IO" %> <%@ import Namespace="System.Data" %> <%@ import Namespace="System.Xml" %> It then runs code in response to the page loadevent. The Page_Load subroutine starts by declaring the content type as text/xml: Sub Page_Load(Src As Object, E As EventArgs) Response.ContentType = “text/xml” The code then declares a DataView object that takes its content from the NewsDSAccessDataSource control: Dim dv As DataView = CType(NewsDS.Select(DataSourceSelectArguments.Empty), . DataView) The DataView allows the page to access the contents of the AccessDataSourcecontrol programmatically. The code uses the contents to generate the RSS feed. It starts by creating a new XmlTextWriter object: Dim XMLFeed as XmlTextWriter = new XmlTextWriter(Response.OutputStream, . Encoding.UTF8) The code sets the stream to Response.OutputStream and the encoding to UTF8. It could also specify a physical file for the XML stream.
We would like to recommend you tested and proved virtual web hosting services, which you will surely find to be of great quality.

Leave a Reply