大家好,我正在尝试使用 C# 在中继器中检索 XML 数据。但它给了我错误这是我的代码
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>chouhan.azad99@gmail.com</emailid>
<Comment>nice flower</Comment>
<CommentTime>6/22/2013 2:43:49 PM</CommentTime>
<status>Y</status>
</comments>
<comments>
</tbcomments>
这给了我错误
请告诉我我错在哪里?