62,074
社区成员
发帖
与我相关
我的任务
分享
<?xml version="1.0" encoding="utf-8" ?>
<item>
<title>
<![CDATA[ 疤痕修复:忘记不愉快的往事 ]]>
</title>
</item>
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="xml.aspx.cs" Inherits="xml" %>
<!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>
</div>
</form>
</body>
</html>
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml;
public partial class xml : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
XmlDocument doc = new XmlDocument();
string Rss = string.Empty;
doc.Load(Server.MapPath("xml.xml"));
XmlNodeList nodelist = doc.GetElementsByTagName("item");
XmlNodeList objItems1;
int i = 0;
if (doc.HasChildNodes)
{
foreach (XmlNode node in nodelist)
{
string title = " ";
string link = " ";
i += 1;
if (node.HasChildNodes)
{
objItems1 = node.ChildNodes;
foreach (XmlNode node1 in objItems1)
{
switch (node1.Name)
{
case "title":
title = node1.InnerText;
break;
case "link":
link = node1.InnerText;
break;
}
if (title != " " && link != " ")
break;
}
Rss += " <a href= ' " + link + " ' target= '_blank '> " + title + " </a> <br> ";
}
}
}
Response.Write(Rss);
}
}