如何合并以下XML代码段:
摘录1:
<drug>
<title>Paracetamol</title>
<indications outputclass="indicationsAndDose">
<title>Indications and dose</title>
<body>
<section outputclass="indicationAndDoseGroup">
<sectiondiv outputclass="therapeuticIndications">
<p outputclass="therapeuticIndication">Some indication 1</p>
</sectiondiv>
</section>
</body>
</indications>
</drug>
代码段2:
<drug>
<title>Abacavir</title>
<indications outputclass="indicationsAndDose">
<title>Indications and dose</title>
<body>
<section outputclass="indicationAndDoseGroup">
<sectiondiv outputclass="therapeuticIndications">
<p outputclass="therapeuticIndication">Some indication 2</p>
</sectiondiv>
</section>
</body>
</indications>
</drug>
接受标准:我需要输出一个XML代码段,它是代码段1和代码段2的超集,但需要以基于n个元素,属性和值的独特方式来完成。
解决方案应该是动态的,因为上述规则可以应用于任何类型的元素,即<title>
<section>
<p>
等
<drug>
<title>Paracetamol</title>
<indications outputclass="indicationsAndDose">
<title>Indications and dose</title>
<body>
<section outputclass="indicationAndDoseGroup">
<sectiondiv outputclass="therapeuticIndications">
<p outputclass="therapeuticIndication">Some indication 1</p>
<p outputclass="therapeuticIndication">Some indication 2</p>
</sectiondiv>
</section>
</body>
</indications>
</drug>
我不确定这是否是您想要的那种合并,因为您的要求非常含糊!但是,它会从您提供的输入中产生输出: