我使用XML SQL 查询从表中检索前 10 个值,然后通过 asp.net 页面显示这些值,以将结果页面的 URL 传递给 flash Game 以打印前 10 个值。我的代码做得很好,我在 aspx 页面上很好地检索了XML查询。但是我单击页面查看源页面,它检索了HTML 页面中的xml值,但 Flash 游戏不会复制这些值。那么如何在 xml 页面中显示 xml 文件呢?.
询问
SELECT DISTINCT TOP (10)
fbid ,
Name as fbname,
Score as fbscore ,
Img as fbimg
FROM
dbo.FB_Player
ORDER BY
Score DESC
FOR XML PATH('Player'), ROOT('AllPlayers')
C# 代码
using (System.Data.SqlClient.SqlConnection c = new SqlConnection(ConfigurationManager.ConnectionStrings["fbgame"].ConnectionString))
using (System.Data.SqlClient.SqlCommand cmd = c.CreateCommand())
{
cmd.CommandText = "procGetPlayerScore";
cmd.CommandType = CommandType.StoredProcedure;
c.Open();
System.Xml.XmlReader r = cmd.ExecuteXmlReader();
string playersXml = cmd.ExecuteScalar().ToString();
string theXML = Server.HtmlEncode(File.ReadAllText(Server.MapPath("Top10.xml")));
lit1.Text= playersXml;
System.Xml.XmlTextWriter w = new System.Xml.XmlTextWriter(Response.Output);
c.Close();
}
使用新代码后出错