这是我的输入 xml 文件
<Collection>
<Teach>
<DeptNo>5613</DeptNo>
<DeptName>Computers</DeptName>
<SubjectNo>234</SubjectNo>
<SubjectName>XML</SubjectName>
<Teacher>Sai</Teacher>
</Teach>
<Teach>
<DeptNo>5617</DeptNo>
<DeptName>Electronics</DeptName>
<SubjectNo>789</SubjectNo>
<SubjectName>Circuits</SubjectName>
<Teacher>Hari</Teacher>
</Teach>
<Teach>
<DeptNo>5613</DeptNo>
<DeptName>Computers</DeptName>
<SubjectNo>239</SubjectNo>
<SubjectName>XSLT</SubjectName>
<Teacher>Suri</Teacher>
</Teach>
<Teach>
<DeptNo>5689</DeptNo>
<DeptName>Maths</DeptName>
<SubjectNo>749</SubjectNo>
<SubjectName>Trigonometry</SubjectName>
<Teacher>Arya</Teacher>
</Teach>
<Teach>
<DeptNo>5617</DeptNo>
<DeptName>Electronics</DeptName>
<SubjectNo>789</SubjectNo>
<SubjectName>Circuits</SubjectName>
<Teacher>Bharat</Teacher>
</Teach>
</Collection>
现在我想要基于 DeptNo 的以下输出 xml 文件,如果它相同,则检查 Subjectno,如果相同,则将教师添加到主题。对主题和部门也做同样的事情。我的输出文件是
<Collection>
<DeptList>
<DeptNo>5613</DeptNo>
<DeptName>Computers</DeptName>
<SubjectList>
<SubjectNo>234</SubjectNo>
<SubjectName>XML</SubjectName>
<TeacherList>
<Teacher>Sai</Teacher>
</TeacherList>
</SubjectList>
<SubjectList>
<SubjectNo>239</SubjectNo>
<SubjectName>XSLT</SubjectName>
<TeacherList>
<Teacher>Suri</Teacher>
</TeacherList>
</SubjectList>
</DeptList>
<DeptList>
<DeptNo>5617</DeptNo>
<DeptName>Electronics</DeptName>
<SubjectList>
<SubjectNo>789</SubjectNo>
<SubjectName>Circuits</SubjectName>
<TeacherList>
<Teacher>Hari</Teacher>
<Teacher>Bharat</Teacher>
</TeacherList>
</SubjectList>
</DeptList>
<DeptList>
<DeptNo>5689</DeptNo>
<DeptName>Maths</DeptName>
<SubjectList>
<SubjectNo>749</SubjectNo>
<SubjectName>Trigonometry</SubjectName>
<TeacherList>
<Teacher>Arya</Teacher>
</TeacherList>
</SubjectList>
</DeptList>
</Collection>