<Peoples>
<People>
<Name>RadheyJang</Name>
<Location>India</Location>
<Work>Software Developer</Work>
<Point>5</Point>
<details>
<People>
<Name>ArunaTiwari</Name>
<Location>India</Location>
<Work>SoFtwareCoder</Work>
<Point>3</Point>
<details/>
<Test>A</Test>
</People>
</details>
<Test>NA</Test>
</People>
</Peoples>
我能够通过使用下面的代码读取Xml。只读部分的XML文件
XDocument xmlDoc = XDocument.Load(str);
var vrresult = from a in xmlDoc.Descendants("People")
select new
{
Name= a.Element("Name").Value,
Location= a.Element("Location").Value,
Point= a.Element("Point").Value
};
GridView1.DataSource = vrresult;
GridView1.DataBind();
但它正在阅读详细内容。我想跳过内的内容元素。请让我知道如何跳过细节内的内容。
我以前从来没见过......该错误信息,你可以请编辑您的答案,并添加GridView的标记,并结合了您的代码XML? – McGarnagle
没有Gridview绑定的问题。我会绑定但在阅读时绑定它给错误。 –
啊,呃。我没有给你答案,但是这个链接可能有帮助:http://www.dotnet247.com/247reference/msgs/5/26129.aspx – McGarnagle