如何读取LINQ
中嵌套后代内的元素我的Xml文件格式
<SmPpProperties>
<PpProperties>
<Project Name="CEESI all 2" CreatedDate="2013-11-18T16:48:54.9452592+01:00" ModifiedDate="2013-11-18T16:48:57.2413905+01:00">
<NuclearSystem>Barium</NuclearSystem>
<TimeLine>
<Clip>
<FilePathFP>FPS\FP001D\Default-wp000-15Oct2012-105001.vxbin</FilePathFP>
</Clip>
</TimeLine>
</Project>
</PpProperties>
</SmPpProperties>
我正在尝试使用C#代码
var SmPpProperties
= from PpProperties in xmldoc.Descendants("PpProperties")
select new
{
from Project in xmldoc.Descendants("Project ")
select new {
*How to proceed*
答案 0 :(得分:0)
var SmPpProperties = from poj in xmldoc.Descendants("Project")
select new {name = poj.Attribute("Name"),
filePath = poj.Element("TimeLine").Element("Clip").Element("FilePathFP").Value};
foreach (var item in SmPpProperties)
{
Console.WriteLine("Name = {0}, File Path = {1}", item.name, item.filePath);
}