例如A.xml B.xml
,我在 arrayList 中有一些 xml 文件,我想合并一些节点,而其余的则保持原样使用 java。我是新手,所以我不知道该怎么做。
一个xml:
<?xml version="1.0" encoding="UTF-8"?>
<nta>
<declaration>
bool A, B;
bool C;
</declaration>
<template>
<location id="1" x="10" y="10"/>
<transition>
<source ref="3"/>
</transition>
</template>
<system> system AND;</system>
</nta>
B.xml:
<?xml version="1.0" encoding="UTF-8"?>
<nta>
<declaration>
int f,k;
bool D;
</declaration>
<template>
<location id="100" x="40" y="89"/>
<transition>
<source col="9"/>
</transition>
</template>
<system> system OR;</system>
</nta>
和输出:
<?xml version="1.0" encoding="UTF-8"?>
<nta>
<declaration>
bool A, B;
bool C;
int f,k;
bool D;
</declaration>
<template>
<location id="1" x="10" y="10"/>
<transition>
<source ref="3"/>
</transition>
</template>
<template>
<location id="100" x="40" y="89"/>
<transition>
<source col="9"/>
</transition>
</template>
<system> system AND, OR;</system>
</nta>
基本上我想在输出 xml 文件中合并declaration
和system
以及其余部分是串行的。如何使用 JAVA 做到这一点?抱歉发了这么长的帖子!!!