1 つの LINQ クエリを使用して、すべての要素と子要素の値を一度に返すことはできますか? 以下のクエリを使用すると、最初の要素を取得できますが、子要素は取得できません。
var query = from c in xDoc.Descendants("file")
orderby c.Name
select new
{
// This gets the main elements
Name = (string)c.Element("name").Value,
};
XML ファイルは次のようになります。
<files>
<file id="1">
<name>A file</name>
<processDetails>
<purpose>It's supposed to get files.</purpose>
<filestoProcess>
<file>alongfile.pgp</file>
<file>Anotherfile.pgp</file>
<file>YetAnotherfile.CSV</file>
</filestoProcess>
<schedule>
<day>Mon</day>
<day>Tue</day>
<time>9:00am</time>
</schedule>
<history>
<historyevent>Eh?</historyevent>
<historyevent>Two</historyevent>
</history>
</processDetails>
</file>
<files>
また、取得したら、子要素にアクセスしてリストボックスやテキストボックスにデータを入力するにはどうすればよいですか?