XML与条件合并

时间:2019-04-09 11:00:02

标签: xml xslt

我有两个XML文件,需要一个解决方案/帮助合并到一个文件中,如下所示,示例中有一个对此有解决方案吗?是python还是任何linux工具?

是,尝试按照以下网址进行操作: how to iterate through xml data to remove next duplicate element using lxml Check and remove duplicated children tags in XML How to delete duplicated elements in XML file Merge multiple XML files from command line

但是,我们将不胜感激

xml file1

<suite name="Daily Run Tests" parallel="tests" thread-count="24">
    <groups>
        <run>
            <include name="mats" />
        </run>
    </groups>
    <listeners>
        <listener class-name="com.common.listener.ExecutionData" />
        <listener class-name="com.common.listener.SuiteData" />
    </listeners>
    <test name="Model_UI_LINUX_FIREFOX1">
        <parameter name="browser"  value="LINUX_FIREFOX"/>
        <parameter name="isMATS" value="true" />
        <classes>
            <class name="com.uiautomation.tests.partner.model.ModelCreation"/>
        </classes>
    </test>
    <parameter name="environment" value="stage" />
    <parameter name="component" value="ABC" />
    <parameter name="envFile" value="ABC" />
</suite>

XML File2:

<suite name="Daily Run Tests" parallel="tests" thread-count="10">
    <groups>
        <run>
            <include name="mats"/>
            <include name="srg"/>
        </run>
    </groups>
    <listeners>
        <listener class-name="com.common.listener.ExecutionData"/>
        <listener class-name="com.common.listener.SuiteData"/>
    </listeners>

    <test name="verify7DayReach">
        <parameter name="browser" value="LINUX_FIREFOX"/>
        <parameter name="isMATS" value="true"/>
        <parameter name="rows" value="{3}" />
        <classes>
            <class name="com.uiautomation.tests.partner.model.ModelEnhancements">
            </class>
        </classes>
    </test>
    <parameter name="environment" value="stage" />
    <parameter name="component" value="ABC" />
    <parameter name="envFile" value="ABC" />
</suite>

现在,我需要一些解决方案以将上述两个xml文件合并为一个: 输出xml :有人对此有解决方案吗?是python吗?

<suite name="Daily Run Tests" parallel="tests"
       thread-count="10">
    <groups>
        <run>
            <include name="mats"/>
            <include name="srg"/>
        </run>
    </groups>
    <listeners>
        <listener class-name="com.common.listener.ExecutionData"/>
        <listener class-name="com.common.listener.SuiteData"/>
    </listeners>

    <test name="verify7DayReach">
        <parameter name="browser" value="LINUX_FIREFOX"/>
        <parameter name="isMATS" value="true"/>
        <parameter name="rows" value="{3}" />
        <classes>
            <class
                    name="com.uiautomation.tests.partner.model.ModelEnhancements">
            </class>
        </classes>
    </test>
    <test name="Model_UI_LINUX_FIREFOX1">
        <parameter name="browser"  value="LINUX_FIREFOX"/>
        <parameter name="isMATS" value="true" />
        <classes>
            <class name="com.uiautomation.tests.partner.model.ModelCreation"/>

        </classes>
    </test>
    <parameter name="environment" value="stage" />
    <parameter name="component" value="ABC" />
    <parameter name="envFile" value="ABC" />
</suite>

0 个答案:

没有答案