ASP.NET - Load xml document from stream (file) datasource

asp.net and XmlDocument - Load xml document from stream (file) datasource
XmlDocumentLoadStream.aspx
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Xml" %>

<script runat="server">
    void Page_Load(object sender, System.EventArgs  e)
    {
        string xmlPath = Request.PhysicalApplicationPath + @"App_Data\ITBookList.xml";
        XmlDocument xmlDoc = new XmlDocument();
        Response.ContentType = "text/xml";
        try
        {
            xmlDoc.PreserveWhitespace = true;
            xmlDoc.Load(xmlPath);
            Response.Write(xmlDoc.InnerXml);
        }
        catch (XmlException xmlEx)
        {
            Response.Write("Xml Exception: " + xmlEx.Message.ToString());
        }
        catch (Exception ex)
        {
            Response.Write("Error occured: " + ex.Message.ToString());
        }
    }
</script>
ITBookList.xml
ITBookList.xml source code here.

   




Related asp.net example