大家好,我正在嘗試使用C#檢索Repeater中的XML數據。但它給我的錯誤 這裏是我的代碼xml數據不是retreiving
var doc = XDocument.Load(Server.MapPath("~/Data/comments.xml"));
var result = doc.Descendants("comments").Where(x => x.Element("postid").Value == Request.QueryString["id"] && x.Element("status").Value == "Y").Select(x => new
{
id=x.Element("id").Value,
name = x.Element("name").Value,
comment = x.Element("Comment").Value,
commenttime = x.Element("Commenttime").Value
//status=x.Element("status").Value
}).OrderByDescending(x => x.id).Take(1);
Repeater2.DataSource = result;
Repeater2.DataBind();
}
,這裏是我的xml
<?xml version="1.0" encoding="utf-8"?>
<tbcomments>
<comments>
<id>1</id>
<postid>4</postid>
<name>azad</name>
<emailid>[email protected]</emailid>
<Comment>nice flower</Comment>
<CommentTime>6/22/2013 2:43:49 PM</CommentTime>
<status>Y</status>
</comments>
<comments>
</tbcomments>
這是給我的錯誤此
,請告訴我,我錯了?
這樣一個小錯誤,我沒有發現我是多麼的愚蠢.. :(順便說一句感謝,現在的工作 –