<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