重複の可能性:
XML ファイルの一部のみを読み取る
<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 を読み取ることができます。
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();
しかし、詳細の目次も読んでいます。details Element 内の Content の読み取りをスキップしたい。詳細属性内のコンテンツをスキップする方法を教えてください。