我编写了一个 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>
如果 LearningObjective 节点的数量小于使用 Linq to XML 的最大学习目标节点数,我想读取此 XML 并计算 LearningObjective 节点的最大值并在 LearningObjectives 节点中写回空的 LearningObjective 节点。我对 Linq 很陌生。任何人都可以帮助我更改此 XML。