【发布时间】:2013-10-19 10:34:03
【问题描述】:
我在 arrayList 中有一些 xml 文件,例如 A.xml B.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>
基本上我想合并declaration 和system,其余的在输出xml 文件中是串行的。如何使用 JAVA 做到这一点?抱歉发了这么长的帖子!!!
【问题讨论】:
-
看看this
-
使用
JDOM它应该是小菜一碟。