虎克的博客

Enthusiasm Biogeography-Biodiversity Informatics-Data Sciences

XML文件处理错误

| Comments

 代码如下:

 

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml;
using System.Xml.Schema;


public partial class Default4 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string xmlFilePath = Request.PhysicalApplicationPath + @"App_Data\Authors.xml";
        XmlDocument xmlAuthors = new XmlDocument();
        Response.ContentType = "text/xml";
        try
        {
            xmlAuthors.PreserveWhitespace = true;
            xmlAuthors.Load(xmlFilePath);
            Response.Write(xmlAuthors.InnerXml);
        }
        catch (XmlException xmlEx)
        {
            Response.Write("XML文件处理错误:" + xmlEx.Message);
        }
        catch (Exception ex)
        {
            Response.Write("Exception:" + ex.Message);
        }

    }
}

 

Comments