次のような XML を記述しました。
<ArrayOfProductLine>
<ProductLine>
<Name>CRM</Name>
<ActionFields>
<ActionField Id="1">
<Name>A2</Name>
</ActionField>
<ActionField Id="2">
<Name>A1</Name>
</ActionField>
</ActionFields>
<ProcessSteps>
<ProcessStep>
<Name>Marketing</Name>
<LearningObjectives>
<LearningObjective ActionFieldId="1">
<Paragraphs>
<Paragraph AllowSelection="false">
<Text>Lern Ziel2</Text>
<Id>1</Id>
</Paragraph>
<Paragraph AllowSelection="false">
<Text>test</Text>
<Id>4</Id>
</Paragraph>
</Paragraphs>
</LearningObjective>
<LearningObjective ActionFieldId="2">
<Paragraphs>
<Paragraph AllowSelection="false">
<Text>Lern Ziel2.1</Text>
<Id>2</Id>
</Paragraph>
</Paragraphs>
</LearningObjective>
</LearningObjectives>
</ProcessStep>
<ProcessStep>
<Name>Vertrieb</Name>
<LearningObjectives>
<LearningObjective ActionFieldId="1">
<Paragraphs>
<Paragraph AllowSelection="false">
<Id>3</Id>
</Paragraph>
</Paragraphs>
</LearningObjective>
</LearningObjectives>
</ProcessStep>
</ProcessSteps>
</ProductLine>
</ArrayOfProductLine>
Linq to XML を使用して、この XML を読み取り、LearningObjective ノードの最大数をカウントし、LearningObjective ノードの数が Learning Objective ノードの最大数より少ない場合は、LearningObjectives ノードに空の LearningObjective ノードを書き戻したいと考えています。私はLinqを初めて使用します。この XML の変更について誰か助けてください。