asp.net页面想读写xml里的格式化文本
我在网上看了个新闻系统,用xml来储存新闻(包括title\content)。但是显示出来没有换行、空格等。就是一堆文字。请问怎么处理?
我贴上各个文件。
//news.xml
<?xml version="1.0" encoding="gb2312"?>
<xinwen>
<news>
<news_id>6</news_id>
<news_title>edd</news_title>
<news_author>果园</news_author>
<news_ly>myself</news_ly>
<news_content>天公是否作美,成为“嫦娥二号”卫星能否按计划发射的焦点。今天下午17时,“嫦娥二号”任务发射场区指挥部举行气象会商,确定10月1日预定“发射窗口”的气象条件适宜卫星发射。
会商中,“嫦娥二号”任务首席气象预报员、西昌卫星发射中心气象室高级工程师江晓华介绍,10月1日预定“发射窗口”气象情况为:气温15℃—17℃,雷电概率较小,小雨,每小时降雨量小于1毫米。经发射场区指挥部会商,“嫦娥二号”卫星可按计划顺利发射。
最近几天,西昌地区天气多变。为确保天气预报及时准确,西昌卫星发射中心气象室的预报人员翻阅近10万张历史天气图,开展雷暴、降水、高空风等多个专题研究,为精确预报预定“发射窗口”气象情况奠定了坚实基础
</news_content>
<news_adddate>2008-1-12 15:39:44</news_adddate>
</news>
</xinwen>
//new_list.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="news_list.aspx.cs" Inherits="news_list" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<table style="width: 594px" align=center>
<tr>
<td align="center" style="width: 594px">
<asp:Label ID="title" runat="server" Font-Size="X-Large" ForeColor="Red"></asp:Label></td>
</tr>
<tr>
<td align="center" style="width: 594px">
作者:<asp:Label ID="author" runat="server"></asp:Label>
来源:
<asp:Label ID="ly" runat="server"></asp:Label>
发布时间:
<asp:Label ID="adddate" runat="server"></asp:Label></td>
</tr>
<tr>
<td style="width: 594px">
<asp:Label ID="content" runat="server"></asp:Label></td>
</tr>
</table>
</div>
</form>
</body>
</html>
//news_list.aspx.cs
public partial class news_list : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string url = Server.MapPath("news.xml");
string news_id = Request.QueryString["news_id"];
if (news_id == "")
{
Response.Redirect("news_manage.aspx");
}
else
{
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(url); //加载XML文档
XmlNode root = xmlDoc.SelectSingleNode("xinwen/news[news_id ='" + news_id + "']");
if (root != null)
{
title.Text = root.ChildNodes[1].InnerText;
author.Text = root.ChildNodes[2].InnerText;
ly.Text = root.ChildNodes[3].InnerText;
content.Text = Server.HtmlEncode(root.ChildNodes[4].InnerText.ToString());
adddate.Text = root.ChildNodes[5].InnerText;
}
}
}
}